Dim hh = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("sp").ConnectionString Dim conn As New SqlConnection(hh) conn.Open() Dim Trans As SqlTransaction = conn.BeginTransaction() Dim sql = "Insert into stu(stu,c1,c2) values(115,'hello','kg')" Dim cmd As New SqlCommand(sql, conn, Trans) sql = "update the set t1='rockman' where the = 102" Dim cmd2 As New SqlCommand(sql, conn, Trans) Try cmd.ExecuteNonQuery() cmd2.ExecuteNonQuery() Trans.Commit() Catch ex As Exception Trans.Rollback() End Try cmd.Dispose() cmd2.Dispose() conn.Close() conn.Dispose()
2月 01, 2013
VB 資料庫插入並更新語法
訂閱:
文章 (Atom)