title: No value given for one or more required parameters - C#/Access
body: <p>This is my first time attempting to read an Access database and write each row to the console. When I execute the application I get thrown an exception that says, "No value given for one or more required parameters" on the following statement:</p>
  
  <p>OleDbDataReader reader = cmd.ExecuteReader();</p>
  
  <p>I'm relatively new to c# programming and after hours of research, I can't figure out what I'm doing wrong. Here's my code:</p>
  
  <pre><code>private void maintenanceToolStripMenuItem_Click(object sender, EventArgs e)
      {
          //Use a variable to hold the SQL statement.
          string inputString = "SELECT Full_Name, First_Name, Last_Name, Company FROM CONTACTS";
  
          try
          {
              //Create an OleDbCommand object and pass in the SQL statement and OleDbConnection object
              OleDbCommand cmd = new OleDbCommand(inputString, conn);
  
              //Send the CommandText to the connection, and then build an OleDbDataReader.
              OleDbDataReader reader = cmd.ExecuteReader();
  
              while (reader.HasRows)
              {
                  while (reader.Read())
                  {
                      Console.WriteLine("\t{0}\t{1}", reader.GetString(1));
                      reader.NextResult();
                  }
              }
              reader.Close();
          }
          catch (Exception ex)
          {
              error_message = ex.Message;
              MessageBox.Show(error_message);
          }
  </code></pre>
  
  <p>In response to the commenters, I'm posting a larger piece of code to eliminate any assumptions and give a better overall picture of what I'm trying to do:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using System.Data.OleDb;
  using System.IO;
  
  namespace AzFloodSquad
  {
      public partial class frm1DefaultScreen : Form
      {
          //Initialize the application
          String conn_string = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\\Databases\\AzFloodSquad\\AzFloodSquad.accdb;Persist Security Info=False;";
          OleDbConnection conn = null;
          String error_message = "";
          String q = "";
          string varReportId = "";
  
      public frm1DefaultScreen()
      {
          InitializeComponent();
      }
  
      //Load the default form
      private void frm1DefaultScreen_Load(object sender, EventArgs e)
      {
          connectToolStripMenuItem.PerformClick();
          contactsToolStripMenuItem.PerformClick();
      }
  
      //Exit the application
      private void exitToolStripMenuItem_Click(object sender, EventArgs e)
      {
          Application.Exit();
      }
  
      //Start the database
      private void connectToolStripMenuItem_Click(object sender, EventArgs e)
      {
          try
          {
              conn = new OleDbConnection(conn_string);
              conn.Open();
              disconnectToolStripMenuItem.Enabled = true;
              connectToolStripMenuItem.Enabled = false;
          }
          catch (Exception ex) { MessageBox.Show(ex.Message); }
      }
  
      //Stop the database
      private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
      {
          try
          {
              conn.Close();
              disconnectToolStripMenuItem.Enabled = false;
              connectToolStripMenuItem.Enabled = true;
          }
          catch (Exception ex) { MessageBox.Show(ex.Message); }
      }
  
      //Clean up database whem form close button clicked
      private void frm1DefaultScreen_FormClosing(object sender, FormClosingEventArgs e)
      {
          disconnectToolStripMenuItem.PerformClick();
      }
  
      private void contactsToolStripMenuItem_Click(object sender, EventArgs e)
      {
          varReportId = "Contacts";
          q = "SELECT * " +
                  "FROM CONTACTS WHERE CONTACTS.CONTACT_TYPE = 'CUSTOMER' " +
                      "OR CONTACTS.CONTACT_TYPE = 'HOMEOWNER' OR CONTACTS.CONTACT_TYPE = 'HOME OWNER' " +
                      "OR CONTACTS.CONTACT_TYPE = 'TENANT'" +
                          "ORDER BY FULL_NAME";
  
          this.Cursor = Cursors.WaitCursor;
          run_Query_Parm(q);
          this.Cursor = Cursors.Default;
      }
  
      //Pull data from the database using the parameter field
      private void run_Query_Parm(String q)
      {
          error_message = "";
          try
          {
              OleDbCommand cmd = new OleDbCommand(q, conn);
              OleDbDataAdapter a = new OleDbDataAdapter(cmd);
  
              DataTable dt = new DataTable();
  
              a.SelectCommand = cmd;
              a.Fill(dt);
  
              results.DataSource = dt;
              results.AutoResizeColumns();
          }
          catch (Exception ex)
          {
              error_message = ex.Message;
              MessageBox.Show(error_message);
          }
      }
  
      //Clear all data from the screen
      private void clearFormToolStripMenuItem_Click(object sender, EventArgs e)
      {
          varReportId = "";
          if (this.results.DataSource != null)
          {
              this.results.DataSource = null;
          }
          else
          {
              this.results.Rows.Clear();
          }
      }
  
      private void maintenanceToolStripMenuItem_Click(object sender, EventArgs e)
      {
          //Use a variable to hold the SQL statement.
          string inputString = "SELECT Full_Name, First_Name, Last_Name, Company FROM CONTACTS";
  
          try
          {
              //Create an OleDbCommand object and pass in the SQL statement and OleDbConnection object
              OleDbCommand cmd = new OleDbCommand(inputString, conn);
  
              //Send the CommandText to the connection, and then build an OleDbDataReader.
              OleDbDataReader reader = cmd.ExecuteReader();
  
              while (reader.HasRows)
              {
                  while (reader.Read())
                  {
                      Console.WriteLine("\t{0}\t{1}", reader.GetString(1));
                      reader.NextResult();
                  }
  
              }
              reader.Close();
          }
          catch (Exception ex)
          {
              error_message = ex.Message;
              MessageBox.Show(error_message);
          }
      }
  </code></pre>
  
  <p>Any help provided would be greatly appreciated. Thanks in advance.</p>