title: transaction in ms access and vb.net
body: <p>I am trying the below code but not getting executed. </p>
  
  <pre><code>Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
      Using con As New OleDbConnection(connectionString)
          Dim tra As OleDbTransaction = Nothing
  
          Try
              con.Open()
              cmd.Transaction = tra
              tra = con.BeginTransaction
              Dim sqlstr As String = "insert into category(cname,comment)  values('" + txtcategory.Text + "','" + txtcomment.Text + "')"
              cmd = New OleDb.OleDbCommand(sqlstr, con)
              cmd.ExecuteNonQuery()
  
              Dim sql As String = "UPDATE tblInvoices SET avail = 1 WHERE (cname = txtcategory.Text)"
              cmd = New OleDb.OleDbCommand(sqlstr, con)
              cmd.ExecuteNonQuery()
              tra.Commit()
  
          Catch ex As Exception
              MsgBox(ex.Message)
              Try : tra.Rollback() : Catch : End Try
  
          End Try
  
  
      End Using
  End Sub
  </code></pre>
  
  <p>I don't understand the transactions.</p>