R
Raj
Hi,
I have a sqlDataAdapter that has a insertcommand and an
updatecommand.
I have initialized the connection to the insertCommand and
updateCommand as mySqlConnection( that is the connection property of
the class ). mySqlDataAdapter is also a property of the object
example
myclassConstructor()
{
mySqlCOnnection = new SqlConnection( myConnString );
}
I use this connection object to init a transaction in another method
example
private void DoThat()
{
SqlTransaction newTransaction = mySqlConnection.BeginTransaction();
//.. init the trans for the command
mySqlDataAdapter.InsertCommand.Transaction = newTransaction;
// ... and then say
mySqlDataAdapter.Update();
newTransaction.Commit();
}
this does not work. I always get the error message saying "Transaction
object not associated with the connection object"
But when I explicitly say
mySqlDataAdapter.InsertCommand.Connection = mySqlConnection;
in the DoThat method, it succeeds. I dont understand that. I have
checked everything with the connection object and nothing seems to be
different.
Can someone help me on this,
TIA,
Raj
I have a sqlDataAdapter that has a insertcommand and an
updatecommand.
I have initialized the connection to the insertCommand and
updateCommand as mySqlConnection( that is the connection property of
the class ). mySqlDataAdapter is also a property of the object
example
myclassConstructor()
{
mySqlCOnnection = new SqlConnection( myConnString );
}
I use this connection object to init a transaction in another method
example
private void DoThat()
{
SqlTransaction newTransaction = mySqlConnection.BeginTransaction();
//.. init the trans for the command
mySqlDataAdapter.InsertCommand.Transaction = newTransaction;
// ... and then say
mySqlDataAdapter.Update();
newTransaction.Commit();
}
this does not work. I always get the error message saying "Transaction
object not associated with the connection object"
But when I explicitly say
mySqlDataAdapter.InsertCommand.Connection = mySqlConnection;
in the DoThat method, it succeeds. I dont understand that. I have
checked everything with the connection object and nothing seems to be
different.
Can someone help me on this,
TIA,
Raj