title: How to make insert query using SQLiteCommand?
body: <p>I have a piece of code, that does not work for me always. Sometimes it returns error about database locked, sometimes about connection.</p>
  
  <p>This is code:</p>
  
  <pre><code>string sql = String.Format("insert into {0}({1}) values({2});", tableName, columns, values);
  SQLiteConnection myConn = null;
  try 
  {
      myConn = new SQLiteConnection(dbConnection);
      myConn.Open();
  
      using(SQLiteCommand sqCommand = new SQLiteCommand(sql))
      {
          sqCommand.CommandText = sql;
          int rows = sqCommand.ExecuteNonQuery();
          return !(rows == 0);
      }
  } 
  finally 
  {
      myConn.Close();
  }
  </code></pre>
  
  <p>What I do wrong?</p>
  
  <p>Error is:</p>
  
  <blockquote>
    <p>No connection associated with this command</p>
  
  <pre><code>   в System.Data.SQLite.SQLiteCommand.InitializeForReader()
     в System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior
  </code></pre>
    
    <p>behavior)
           в System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(CommandBehavior
    behavior)
           в System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()</p>
  </blockquote>
  
  <p>In line:</p>
  
  <pre><code>int rows = sqCommand.ExecuteNonQuery();
  </code></pre>