title: The OdbcParameterCollection only accepts non-null OdbcParameter type objects
body: <p>Just as a little heads up, I'm completely new to this whole "coding" thing in general, so forgive me if I don't make myself clear and just let me know if I can tell you anything else. I've been Googling for days and couldn't find anything, I'm not sure if that's just bad on my part, or just because I'm really new and wouldn't know the solution if it were right in front of my face.</p>
  
  <p>When I go to test the application (Visual Studio 2010), everything shows up and I can put in information in my text boxes, but once I press submit, this error pops up:</p>
  
  <blockquote>
    <p>"The OdbcParameterCollection only accepts non-null OdbcParameter type objects. Parameter name: value"</p>
  </blockquote>
  
  <p>and it points to this line of code:</p>
  
  <pre><code>cmd.Parameters.Add(pram[i]);
  </code></pre>
  
  <p>I don't know if I'm setting the parameters wrong or INSERT INTO statement wrong or what. I can show you the ASP.net code also if needed. Let me know if I can give you any more info! Thank you in advanced!</p>
  
  <p>My C# code is this:</p>
  
  <pre><code> private void execution(string eventspecialist, string phone, string phone2, string firstname, string lastname, string besttime, string companyname, string nonprofit, string requesteddate, string requestedtime, string attendance, string eventtype, string other, string leadsource, string notes, string catering, string bar, string damagedeposit, string dancefloor)
  {
  
  
      OdbcConnection conn = new OdbcConnection(GetConnectionString());
  
      string sql = "INSERT INTO tblcontacts (eventspecialist, phone, phone2, firstname, lastname, besttime, companyname, nonprofit, requesteddate, requestedtime, attendance, eventtype, other, leadsource, notes, catering, bar, damagedeposit, dancefloor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  
      try
      {
          conn.Open();
          OdbcCommand cmd = new OdbcCommand(sql, conn);
  
          cmd.Parameters.Add("@SPECIALIST", OdbcType.NVarChar, 50).Value = eventspecialist;
          cmd.Parameters.Add("@CUST_PHONE1", OdbcType.NVarChar, 50).Value = phone;
          cmd.Parameters.Add("@CUST_PHONE2", OdbcType.NVarChar, 50).Value = phone2;
          cmd.Parameters.Add("@CUST_FNAME", OdbcType.NVarChar, 50).Value = firstname;
          cmd.Parameters.Add("@CUST_LNAME", OdbcType.NVarChar, 50).Value = lastname;
          cmd.Parameters.Add("@BEST_TIME", OdbcType.NVarChar, 50).Value = besttime;
          cmd.Parameters.Add("@COMPANY_NAME", OdbcType.NVarChar, 225).Value = companyname;
          cmd.Parameters.Add("@NONPROFIT", OdbcType.NVarChar, 1).Value = nonprofit;
          cmd.Parameters.Add("@REQ_DATE", OdbcType.NVarChar, 10).Value = requesteddate;
          cmd.Parameters.Add("@REQ_TIME", OdbcType.NVarChar, 20).Value = requestedtime;
          cmd.Parameters.Add("@ATTENDANCE", OdbcType.NVarChar, 50).Value = attendance;
          cmd.Parameters.Add("@EVENT_TYPE", OdbcType.NVarChar, 50).Value = eventtype;
          cmd.Parameters.Add("@OTHER_DESC", OdbcType.NVarChar, 225).Value = other;
          cmd.Parameters.Add("@LEAD_SOURCE", OdbcType.NVarChar, 50).Value = leadsource;
          cmd.Parameters.Add("@NOTES", OdbcType.NVarChar, 225).Value = notes;
          cmd.Parameters.Add("@CATERING", OdbcType.NVarChar, 1).Value = catering;
          cmd.Parameters.Add("@BAR", OdbcType.NVarChar, 1).Value = bar;
          cmd.Parameters.Add("@DAMAGE_DEPOSIT", OdbcType.NVarChar, 19).Value = damagedeposit;
          cmd.Parameters.Add("@DANCE_FLOOR", OdbcType.NVarChar, 19).Value = dancefloor;
  
  
  
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();
      }
      catch (System.Data.Odbc.OdbcException ex_msg)
      {
  
          string msg = "Error occured while inserting";
          msg += ex_msg.Message;
          throw new Exception(msg);
      }
      finally
      {
  
          conn.Close();
      }
  }
  protected void Page_Load(object sender, EventArgs e)
  {
  }
  protected void submit_Click(object sender, EventArgs e)
  {
      execution(eventspecialist.Text, phone.Text, phone2.Text, firstname.Text, lastname.Text, besttime.SelectedItem.Text, companyname.Text, nonprofit.Text, requesteddate.Text, requestedtime.Text, attendance.Text, eventtype.SelectedItem.Text, other.Text, leadsource.SelectedItem.Text, notes.Text, catering.Text, bar.Text, damagedeposit.Text, dancefloor.SelectedItem.Text);
  
      conform.Visible = true;
      Control frm = this.FindControl("form1");
      foreach (Control ctrl in frm.Controls)
      {
          if (ctrl is TextBox)
          {
              ((TextBox)ctrl).Text = "";
          }
          else if (ctrl is CheckBox)
          {
              ((CheckBox)ctrl).Checked = false;
          }
          else if (ctrl is DropDownList)
          {
              ((DropDownList)ctrl).SelectedIndex = 0;
          }
      }
  }
  </code></pre>