Re: No value given for one or more required parameters

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: mp (plamir_at_volja.net)
Date: 04/01/04


Date: Thu, 1 Apr 2004 15:19:29 +0200

Thanks Jon.
I understand but look this.
When i use following line of code
String insertCmd = "insert into Authors (au_id, au_lname) values (@Id,
@LName)";

OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);

myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar, 11));

myCommand.Parameters["@Id"].Value = txtID.Text;
/*Server.HtmlEncode(txtID.Text);*/

myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
40));

myCommand.Parameters["@LName"].Value = txtLName.Text; /*
Server.HtmlEncode(txtLName.Text); */

myCommand.Connection.Open();

myCommand.ExecuteNonQuery();

Error is:

Operation must use an updateable query.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.

Why this query is not updateable?

Thanks

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1ad6240c9764e1ee98a541@msnews.microsoft.com...
> mp <plamir@volja.net> wrote:
> > No value given for one or more required parameters.
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information
> > about the error and where it originated in the code.
>
> <snip>
>
> > Code is following:
> > ...
> > String insertCmd = "insert into Authors (au_id, au_lname, au_fname,
phone,
> > address, city, state, zip, contract) values (@Id, @LName, @FName,
@Phone,
> > @Address, @City, @State, @Zip, @Contract)";
> >
> > OleDbCommand myCommand = new OleDbCommand(insertCmd, thisConnection);
> >
> > myCommand.Parameters.Add(new OleDbParameter("@Id", OleDbType.VarChar,
11));
> >
> > myCommand.Parameters["@Id"].Value = txtID.Text;
> > /*Server.HtmlEncode(txtID.Text);*/
> >
> > myCommand.Parameters.Add(new OleDbParameter("@LName", OleDbType.VarChar,
> > 40));
> >
> > myCommand.Parameters["@LName"].Value = txtLName.Text; /*
> > Server.HtmlEncode(txtLName.Text); */
> >
> >
> > myCommand.Connection.Open();
> >
> > myCommand.ExecuteNonQuery();
>
> Well, you've specified 9 parameters in the query, and only filled in
> values for 2 of them. What did you expect to happen about the other 7?
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too