none
Using OLEDB Update DB2 Exception Occurs? RRS feed

  • Question

  • Hi there,

    I am using OLEDB to update/Insert DB2 Tables. Some tables work fine, some tables with following exception:

    "System.Data.OleDb.OleDbException:The table is an invalid state for the operation. The reason code is SQLSTATE:55019,SQLCODE:-7008"

    Here is my C# code:

     public void UpdateDB2(StringCollection sql_cmds, string ConnectionString)
     {

          OleDbConnection con = new OleDbConnection(ConnectionString);
          OleDbTransaction trans = null;
          string sql_syntax = "";
          try
         {
              con.Open();
              trans = con.BeginTransaction();
              OleDbCommand comm = new OleDbCommand();
              comm.Connection = con;
              comm.Transaction = trans;

              int count = sql_cmds.Count;
              for (int i = 0; i < count; i++)
             {
                 comm.CommandText = sql_cmds[i];
                 sql_syntax = sql_cmds[i];
                 comm.ExecuteNonQuery();
              }

               trans.Commit();
               con.Close();
        }

        catch (Exception exp)
        {
             if (trans != null)
             trans.Rollback();

             if (con.State != ConnectionState.Closed)
                 con.Close();

             this.WriteEventLog("UpdateDB2_Error", "Update DB with Transaction Error.\n SQL Syntax:\n" + sql_syntax + ".\n" + exp.ToString());
                    throw (exp);
        }
    }

    Any help would be most appreciated.

    Thanks.

     

     


    Monday, September 26, 2011 9:42 AM

Answers

All replies