Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think your problem is that you should close your connection ASAP.</p> <p>Here is how I would write the ProcessBatch method:</p> <pre><code>private void ProcessBatch() { using (OleDbConnection connection = new OleDbConnmection(ConnectionString)) { connection.Open(); { String sql = "select recid,action,parm1,parm2,parm3,parm4,targetfile from alarm.batch where recid&gt;0 order by recid"; OleDbCommand cmd = new OleDbCommand(sql, connection); using (OleDbDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { int n = 0; string recid_str = reader[n++].ToString(); string action = reader[n++].ToString(); string parm1 = reader[n++].ToString(); string parm2 = reader[n++].ToString(); string parm3 = reader[n++].ToString(); string parm4 = reader[n++].ToString(); string targetfile = reader[n++].ToString(); sql = "update alarm.batch set recid= -" + recid_str + " where recid=" + recid_str; cmd = new OleDbCommand(sql, connection); cmd.ExecuteNonQuery(); if (ProcessBatchItem(action, parm1, parm2, parm3, parm4, targetfile)) { sql = "delete from alarm.batch where recid= -" + recid_str; cmd = new OleDbCommand(sql, connection); cmd.ExecuteNonQuery(); } } } } } } </code></pre> <p>Note that the using-statement automatically closes the connection when the ProcessBatch is finished. If E.g. ProcessBatchItem requires a connection you should hand over the connection as a parameter.</p> <p>You might also consider using a OleDbTransation.</p> <p>In your application you should remove the Connection-property.</p> <p>Good luck with your application.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload