求人情報

しばらくお待ちください。

コンタクトレンズ通販

2008/10/29

VB.NETでのDBアクセスは(INSERT,UPDATE)

Using connection As New SqlClient.SqlConnection(DB設定)
Dim command As SqlClient.SqlCommand = connection.CreateCommand()
connection.Open()
command.Transaction = connection.BeginTransaction()

Try
'---------------------------------------------------------------------
'tbl_Aの処理
'---------------------------------------------------------------------
 strSQL = String.Format("UPDATE tbl_A SET status=1,  UserID='{0}', RegTime='{1:yyyy/MM/dd HH:mm:ss}' WHERE ACode='{2}'", userID, Now, a)
 command.CommandText = strSQL
 command.ExecuteNonQuery()
'---------------------------------------------------------------------
'tbl_Bの処理
'---------------------------------------------------------------------
Dim expirTime As DateTime = Now.AddDays(日数)
 command.CommandText = String.Format("INSERT INTO tbl_B(EmailAddr, UserID, RegistTime, ExpirTime) VALUES ('{0}', '{1}', '{2:yyyy/MM/dd HH:mm:ss}', '{3:yyyy/MM/dd HH:mm:ss}')", email, userID, Now, expirTime)
 command.ExecuteNonQuery()
 command.Transaction.Commit()

Catch ex As Exception
 command.Transaction.Rollback()
 Return AAAAA
End Try
End Using

関連記事:


0 件のコメント:

記事のラベル

  • Apache
  • BASP21
  • Blogger関連
  • CMS
  • CSS
  • Google
  • JavaScript
  • log4php
  • MYSQL
  • nmap
  • PHP
  • PowerEdgeT105
  • Rationall Clear Case
  • SMTP
  • SSL
  • VB.NET
  • WEB
  • Web API
  • xCore関連
  • XML-RPC送信ツール
  • ZenCart
  • アクセス解析
  • コーディング
  • サンプル
  • ストリーミング
  • その他
  • ツール関連
  • ディザスタリカバリ
  • ブログパーツ
  • 求人情報等
  • 書籍紹介
  • 小遣い稼ぎ
  • 日経SYSTEMS
  • 本日の作業
  • 無停電停止装置

関連IT用語 by e-Words

マイブログ リスト