I did this code:
Code:
 Private Sub Transfer_Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Transfer_Btn.Click
         Dim oleTran As OleDb.OleDbTransaction
        Try
            Using con As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=BankAccount.mdb")
                con.Open()
                oleTran = con.BeginTransaction
                cmd = New OleDbCommand("Update BankAccount set CurrentBalance= CurrentBalance-@amount where BankName=@bankname and  AccountNo=@accountno", con)
                cmd.Parameters.AddWithValue("@amount", TextBox3.Text)
                cmd.Parameters.AddWithValue("@bankname", ComboBox1.Text)
                cmd.Parameters.AddWithValue("@accountno", ComboBox2.Text)
                cmd.Transaction = oleTran
                Dim rowseffected As Integer = cmd.ExecuteNonQuery()
                Dim cmd1 As New OleDbCommand
                cmd1 = New OleDbCommand("Update BankAccount set CurrentBalance= CurrentBalance+@amount where bankname=@BankName and  AccountNo=@accountno", con)
                cmd1.Parameters.AddWithValue("@amount", TextBox3.Text)
                cmd1.Parameters.AddWithValue("@bankname", ComboBox3.Text)
                cmd1.Parameters.AddWithValue("@accountno", ComboBox4.Text)
                cmd1.Transaction = oleTran
                Dim rowseffected1 As Integer = cmd1.ExecuteNonQuery()
                Dim cmd2 As New OleDbCommand
                cmd2 = New OleDbCommand("Select CurrentBalance from BankAccount where BankName=@bankname and AccountNo=@accountno", con)
                cmd2.Parameters.AddWithValue("@bankname", ComboBox1.Text)
                cmd2.Parameters.AddWithValue("@accountno", ComboBox2.Text)
                Dim CurrentBal As Decimal = CDec(cmd2.ExecuteScalar())
                Dim Amount As Decimal
                Decimal.TryParse(TextBox3.Text, Amount)
                If CurrentBal < Amount Then
                    oleTran.Rollback()
                End If
                If ComboBox1.Text = ComboBox3.Text And ComboBox2.Text = ComboBox4.Text Then
                    MsgBox("You cant transfer the money in the same account")
                End If
                oleTran.Commit()
            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
        End Try
 End Sub
I am getting this error message.....
Attachment 72609
This is the first time i am working with the oledbtransaction.......
Where lies the fault in my above code?
Need some help!!!