Prepared statement expects parameter which was not supplied

  • Thread starter Thread starter jfturcott
  • Start date Start date
J

jfturcott

Prepared statement '(@p1 int,@p2 tinyint,@p3 varchar(8000),@p4
varchar(8000),@p5 bit' expects parameter @p1, which was not supplied.

I get the above error when trying to update a datagridview to the sql
database. I am using the commandbuilder because the datagridview can
be saving 8 different types of data (to different tables) depending
upon the selection made in a Treeview control.

The same code without the parameters line works properly for other
sources of data:

Here is the affected section of code.

daQuestionItems.UpdateCommand = CB.GetUpdateCommand
daQuestionItems.UpdateCommand.Parameters("@p1").Value =
CInt(s.SurveyId)
daQuestionItems.Update(dsChanges, "questionItems")

Iterating the parameters collection show this value is populated, and
trying to do an add fails because the parameter is already declared.

I'm working in vb2005 with sql server 2000.

Any help would be appreciated.

jt
 
Have you checked the query and other info generated by the CommandBuilder?
Most people don't use that because it's kind of kludgey. You could try
building your own properties for it, like the query, and see if it works
that way, and if it does, then you have more information about what might
be wrong with it.

Robin S.
 
Back
Top