Saturday, March 07, 2009

No value given for one or more required parameters. (ADO Error)

There are many reasons for this error:

  1. Parameter name not spelt correctly
  2. Case is not correct in parameter (firstname instead of FirstName )
  3. Passing incorrect type, for example, numeric instead of string - pass the string within quote


  1. Anonymous3:29 AM

    thanks for posting

  2. how can pass variables in values

  3. OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/syedzohererj/Documents/Database1.accdb;Persist Security Info=False;");
    string commandString = "select * from Customer where ID=@Account";
    OleDbCommand cmd = con.CreateCommand();
    cmd.Parameters.Add("@Account", OleDbType.Integer).Value = int.Parse(textBox1.Text);
    OleDbDataAdapter da = new OleDbDataAdapter(commandString, con);
    DataSet ds = new DataSet();
    da.Fill(ds, "table1");
    int curr = (int.Parse(textBox1.Text) - 1);

    DataTable dt = ds.Tables["table1"];
    textBox2.Text = dt.Rows[curr]["employee"].ToString();
    textBox3.Text = dt.Rows[curr]["Address"].ToString();
    textBox4.Text = dt.Rows[curr]["contact"].ToString();

  4. Anonymous9:57 AM

    Here's a new reason why it could generate that error statement: list of header names is too long! To check examine your range definition (ctrl-F3). If the last column header is truncated, you will know you have a problem

  5. saved a life cause 1 of my parameters was spelled incorrectly and i never saw it and i was looking and getting frustrated. Thanks


Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.