Re: No value given for one or more required parameters

From: Ron Allen (rallen_at__nospam_src-us.com)
Date: 04/01/04


Date: Thu, 1 Apr 2004 09:14:40 -0500

mp,
    Since this looks like pubs from SQL 2000 you have three more 'required'
fields to fill in as au_fname, phone, and contract are specified as NOT NULL
and do not have default values. So the insert will be rejected as violating
table constraints.

Ron Allen
"mp" <plamir@volja.net> wrote in message
news:Oz02kv%23FEHA.1368@TK2MSFTNGP11.phx.gbl...
> 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
>
>



Relevant Pages

  • Re: No value given for one or more required parameters
    ... No this is not pubs from SQL 2000. ... There is no required filelds. ... >> Operation must use an updateable query. ...
    (microsoft.public.dotnet.languages.csharp)
  • Update all fields
    ... >I get an error message "Must be an updateable query for ... >the following SQL: ... >from Table1 Where Month_name is not null) ...
    (microsoft.public.access.queries)
  • Update all fields
    ... I get an error message "Must be an updateable query for ... the following SQL: ... from Table1 Where Month_name is not null) ...
    (microsoft.public.access.queries)