title: Use of unassigned local variable c# using OleDbDataReader
body: <p>I am having a problem and have been banging my head aginst a wall... I keep getting a "Use of unassigned local variable" when I call "dbReader = dbCommand.ExecuteReader();" it says the Use of unassigned local variable 'dbCommand'. Would someone please take a look at this and tell me where and what I am doing wrong? Thank you in advanced.</p>
  
  <pre><code>    public void computerList()
      {
          //Create SQL strings
          string sql = "SELECT Computers FROM [Sheet1$]";
  
          //Create the instances
          OleDbConnection dbConnection;
          OleDbDataAdapter dbAdapter;
          OleDbCommand dbCommand;
          OleDbDataReader dbReader; 
          DataTable dataTable;
  
          //Call the instance
          dbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.4.0;Data Source=Y:\\\\serverName\\Share\\document.xls;Extended Properties='Excel 12.0 Xml;HDR=YES'");
          dbAdapter = new OleDbDataAdapter(sql, dbConnection);
          dataTable = new DataTable();
          dbConnection.Open();
          dbReader = dbCommand.ExecuteReader();
  
          while (dbReader.Read())
          {
              int iRow = dataTable.Rows.Count;
              //MessageBox.Show("Count " + iRow.ToString());
              //MessageBox.Show(dbReader.ToString());
              for (int i = 0; i &lt; iRow; i++)
              {
                  int loopID = i;
                  string rowData = dataTable.TableName;
                  MessageBox.Show("Count" + loopID);
                  MessageBox.Show(dbReader.GetString(iRow));
              }
  
          }
          //Close Connections 
          dbReader.Close();
          dbConnection.Close();
      }
  </code></pre>