Re: Command Parameters, Did they change?
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?