adwaitjoshi
Active member
- Joined
- Dec 29, 2005
- Messages
- 38
- Programming Experience
- 1-3
Hi I have the following code
the above code works fine out of a transaction. When I say BeginTransaction I get an error
now I get an error
VB.NET:
Dim cb As New SqlCommandBuilder(_sqladapter)
_sqladapter.UpdateCommand = cb.GetUpdateCommand()
_sqladapter.InsertCommand = cb.GetInsertCommand()
_sqladapter.DeleteCommand = cb.GetDeleteCommand()
_sqladapter.Update(_dataset.Tables(_tablename))
hence I added the codeError updating SQL Adapter. The exception Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized..
VB.NET:
_sqladapter.UpdateCommand.Transaction = gobjDatabase.CurrentTransaction
_sqladapter.InsertCommand.Transaction = gobjDatabase.CurrentTransaction
_sqladapter.DeleteCommand.Transaction = gobjDatabase.CurrentTransaction
_sqladapter.UpdateCommand = cb.GetUpdateCommand()
_sqladapter.InsertCommand = cb.GetInsertCommand()
_sqladapter.DeleteCommand = cb.GetDeleteCommand()
_sqladapter.Update(_dataset.Tables(_tablename))
what am I doing wrong? Can someone please guide me?Error updating SQL Adapter. The exception Object reference not set to an instance of an object..