title: Sqlite with c# and where clause
body: <p>I have the following code working fine, but how do I add a where clause in.</p>
  
  <p>Been trying the following  string:
   sql = "select [ip_address], [name], [model], [mac_address], [operating_system], [current_user]from [devices] where [ip_address] = @192.168.0.56";</p>
  
  <pre><code>using System;
  using System.Data.SQLite;
  using System.IO;
  
  
  namespace SQLiteSamples
  {
      class Program
      {
          // Holds our connection with the database
          SQLiteConnection m_dbConnection;
  
  
          public string Info { get; private set; }
  
          static void Main(string[] args)
          {
              Program p = new Program();
          }
  
          public Program()
          {
  
              connectToDatabase();            
              printResult();
          }
  
  
  
          // Creates a read only connection to spiceworks database file.
          void connectToDatabase()
          {
              //m_dbConnection = new SQLiteConnection(@"Data Source=\\spiceworks\db\spiceworks_prod.db;Version=3;Read Only=True");
              m_dbConnection = new SQLiteConnection(@"Data Source=C:\Temp\ZipSampleExtract\db\spiceworks_prod.db;Version=3;Read Only=True");        
              m_dbConnection.Open();
          }
  
  
  
  
          // Writes the output from spiceworks table devices.
          void printResult()
          {
  
              string sql = "select [ip_address], [name], [model], [mac_address], [operating_system], [current_user]from [devices]";
              SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
              SQLiteDataReader reader = command.ExecuteReader();
  
              while (reader.Read())
  
             Console.WriteLine("ip_address: " + reader["ip_address"] + "  " + reader["name"] + "  " + reader["model"] + "  " + reader["mac_address"]+"  " + reader["operating_system"] + "  " + reader["current_user"]);
             Info = Convert.ToString(Console.ReadLine());
             File.WriteAllText("E:\\johnb.txt", Info);
  
         }
  
      }
  }
  </code></pre>