Hi Dear LacOniC,
What Controls you have on your form? Is it a webform, winform?
But In anycase, what you can do is , write code like this
Dim myConnection As New SqlConnection(myConnString)
myConnection.Open()
Dim myCommand As SqlCommand = myConnection.CreateCommand()
Dim myTrans As SqlTransaction
' Start a local transaction
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadC ommitted,
"SampleTransaction")
' Must assign both transaction object and connection
' to Command object for a pending local transaction
myCommand.Connection = myConnection
myCommand.Transaction = myTrans
Try
myCommand.CommandText = "Insert into Table1(Field1, Field2,.....)
VALUES ('" & textbox1.text.tostring() & "', '" & textbox2.text.tostring() &
"')"
myCommand.ExecuteNonQuery()
myCommand.CommandText = "Insert into Table2(Field1, Field2,.....)
VALUES ('" & textbox1.text.tostring() & "', '" & textbox2.text.tostring() &
"')"
myCommand.ExecuteNonQuery()
myTrans.Commit()
Console.WriteLine("Both records are written to database.")
Catch e As Exception
Try
myTrans.Rollback("SampleTransaction")
Catch ex As SqlException
If Not myTrans.Connection Is Nothing Then
Console.WriteLine("An exception of type " &
ex.GetType().ToString() & _
" was encountered while attempting to roll back
the transaction.")
End If
End Try
Console.WriteLine("An exception of type " & e.GetType().ToString() & _
"was encountered while inserting the data.")
Console.WriteLine("Neither record was written to database.")
Finally
myConnection.Close()
End Try
End Sub 'RunSqlTransaction
For Anything & Everything, Please Let Me Know,
Bye
Venkat_KL