none
OleDbCommand.Transaction failure RRS feed

  • Question

  • I get an error at cmdm.Transaction lines because cmdm.Transaction is null. How can I set it up to make it working? I do not understand the principle behind it. I mean I do understand how it works on Db but cannot comprehend why it is an object separate from OlebCommand and how I can instantiate it.

     

    comndText = "INSERT INTO " + dataTableName +

    " numeric_id, named VALUES '" + numeric_id + "', '" + this.txtBoxFindWords.Text.Trim ( ) + "'";

    cmdm.CommandText = comndText;

    cmdm.Transaction.Begin ( IsolationLevel.Serializable );

    cmdm.ExecuteNonQuery ( );

    cmdm.Transaction.Commit ( );

    comndText = "INSERT INTO crossRefTable pointer_one, pointer_two VALUES '" +

    parentNumeric_id + "', '" + numeric_id + "'";

    cmdm.Transaction.Begin ( IsolationLevel.Serializable );

    cmdm.ExecuteNonQuery ( );

    cmdm.Transaction.Commit ( );

     

    If I remove the Transaction statements everything will work but it seems to me I need them.

     

    Thanks.

    Monday, October 8, 2007 4:41 PM