Transection Dim conn As New SqlConnection(sqlConn) Dim tr As SqlTransaction Dim cmd As New SqlCommand Try sqlconn.Open() tr = sqlconn.BeginTransaction() cmd.Connection = conn cmd.Transaction = tr cmd.CommandText = "insert into Table1 (fields1,fields2,fields3) values (" & object1.text & " , " & object2.text & "," & object3.text &")" cmd.ExecuteNonQuery() cmd.CommandText = "insert into Table2 (fields1,fields2,fields3) values (" & object1.text & " , " &object2.text & "," & object3.text &")" cmd.ExecuteNonQuery() tr.Commit() Catch ex As Exception tr.Rollback() Label1.Text = "ERR " & ex.ToString End Try conn. Close()
บทความ
กำลังแสดงโพสต์จาก กันยายน, 2008