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

4 comments:

  1. how can pass variables in values

    ReplyDelete
  2. 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();
    ds.AcceptChanges();

    ReplyDelete
  3. 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

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

    ReplyDelete

StumbleUpon
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.