Re: Command Parameters, Did they change?
Posted by: Chris Cline
Date: December 14, 2004 09:55AM

Ok, I have created a dataadapter with INSERT, UPDATE, SELECT, and DELETE commands. The insert command has the following CommandText:

"INSERT INTO product (Product_IsPublished, Product_CatsCode, Product_Title, Product_Status, Product_Author_ID, Product_ISBN, Product_Code, Product_Abrev, Product_Type, Product_Package_Style, Product_Printer_ID, Product_Duplicate, Product_IsActive, Product_List_Price, Product_Manufacture_ID, Product_Tax_Class_ID, Product_Weight, Product_Edition, Product_Exam_Price, Product_Image, Product_Profes_Price, Product_Pages ) VALUES (?Product_IsPublished, ?Product_CatsCode, ?Product_Title, ?Product_Status, ?Product_Author_ID, ?Product_ISBN, ?Product_Code, ?Product_Abrev, ?Product_Type, ?Product_Package_Style, ?Product_Printer_ID, ?Product_Duplicate, ?Product_IsActive, ?Product_List_Price, ?Product_Manufacture_ID, ?Product_Tax_Class_ID, ?Product_Weight, ?Product_Edition, ?Product_Exam_Price, ?Product_Image, ?Product_Profes_Price, ?Product_Pages ); SELECT LAST_INSERT_ID() AS Product_ID"


I add a new datarow with data to the datatable, then I call dataadpater.update();
(Sorry, my code is very long so I'm not providing all of it here)

Now, once the Update() is called I get Exception: Parameter "?Product_IsPublished" must be defined.

Tracing the code out I found the code that was throwing the exception:

private bool SerializeParameter( PacketWriter writer, string parmName )
{
if (! parameters.Contains( parmName ))
{
// if we are using old syntax, we can't throw exceptions for parameters
// not defined.
if (connection.Settings.UseOldSyntax) return false;
throw new MySqlException("Parameter '" + parmName + "' must be defined");
}
MySqlParameter parameter = parameters[parmName];
parameter.Serialize( writer, false );
return true;
}

I then noticed parmName contained "?Product_IsPublished" which you are using to check against parameters collection and it returns false because the parameters contains "Product_IsPublished" and not "?Product_IsPublished".

This help?

Options: ReplyQuote


Subject
Written By
Posted
Re: Command Parameters, Did they change?
December 14, 2004 09:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.