title: Error : "Cannot set commandtext while a datareader is active" with ExecuteNonQuery()
body: <p>I listen a data stream and store data as insert statements in a <code>ConcurrentQueue</code> and insert the data with bulk insertion using a <code>System.Threading.Timer</code> with an interval of 1000 . The whole scenario runs on a static class.
  Here is the code:  </p>
  
  <pre><code>static void timer_Elapsed(object sender, ElapsedEventArgs e)
  {
      if (queryQueue.IsEmpty)
          return;
      string text = "";
  //bulkBuilder is StringBuilder.
  //queryQueue is ConcurrentQueue
      bulkBuilder.AppendLine("PRAGMA synchronous = 0;PRAGMA count_changes = FALSE;PRAGMA journal_mode=OFF;Begin;");
      while (queryQueue.TryDequeue(out text))
      {
          bulkBuilder.Append(text);
          bulkBuilder.AppendLine(";");
      }
      bulkBuilder.AppendLine("Commit;");
  
      try
      {
          sqlCommand.CommandText = bulkBuilder.ToString();
          sqlCommand.ExecuteNonQuery();
      }
      catch (System.Exception ex)
      {
          Console.WriteLine("Error while inserting Data : " + ex.Message);
      }
      finally
      {
          bulkBuilder.Clear();
      }
  
  }
  </code></pre>
  
  <p>Funny thing is, <code>sqlCommand</code> is used just for insertion, just to <code>ExecuteNonQuery()</code> in this timer. And time to time a get an error saying "Cannot set commandtext while a datareader is active." This is nonsense since this code has nothing to do with the inner <code>SQLiteDataReader</code> in the <code>sqlCommand</code>.</p>
  
  <p>How can I get rid of this error?</p>