By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

Error Updating Via DataAdapter

P: n/a
Per a previous question I posted on this group, I have a Web Service
which returns a DataSet (just a simple SELECT query grabbed from a
database). My application calls the web service function and uses the
DataSet to populate a DataGrid. I edit some of the fields, then pass
that DataSet's .GetUpdates DataSet to another Web Service, which
performs the following code (sorry for any wrapping):

public string UpdateDataSet(System.Data.DataSet dataSetUpdate)
mySqlConnection = new MySqlConnection(stringDatabaseConnection);
mySqlDataAdapter = new MySqlDataAdapter("SELECT FID, Name FROM
Media_Formats", mySqlConnection);

MySqlCommand mySqlCommandInsert = new MySqlCommand("INSERT INTO
Media_Formats (Name) VALUES (?)", mySqlConnection);
mySqlCommandInsert.Parameters.Add(new MySqlParameter("Name",
MySqlDbType.VarChar, 100));
mySqlDataAdapter.InsertCommand = mySqlCommandInsert;

MySqlCommand mySqlCommandUpdate = new MySqlCommand("UPDATE
Media_Formats SET Name=? WHERE FID=?", mySqlConnection);
mySqlCommandUpdate.Parameters.Add(new MySqlParameter("Name",
MySqlDbType.VarChar, 100));
mySqlCommandUpdate.Parameters.Add(new MySqlParameter("FID",
mySqlDataAdapter.UpdateCommand = mySqlCommandUpdate;

MySqlCommand mySqlCommandDelete = new MySqlCommand("DELETE FROM
Media_Formats WHERE FID=?", mySqlConnection);
mySqlCommandDelete.Parameters.Add(new MySqlParameter("FID",
mySqlDataAdapter.DeleteCommand = mySqlCommandDelete;

return Boolean.TrueString;
catch (Exception e)
return "ERROR: DataAccess-UpdateDataSet - " + e.ToString();

However, this function is returning the following error caught by the
exception handler (sorry for any wrapping):

ERROR: DataAccess-UpdateDataSet - MySql.Data.MySqlClient.MySqlException:
Parameter '?' must be defined
in <0x000b8> MySql.Data.MySqlClient.MySqlCommand:SerializeParam eter
(MySql.Data.MySqlClient.PacketWriter writer, System.String parmName)
in <0x0043e> MySql.Data.MySqlClient.MySqlCommand:PrepareSqlBuff ers
(System.String sql)
in <0x000a7> MySql.Data.MySqlClient.MySqlCommand:ExecuteReader
(CommandBehavior behavior)
in <0x0000d>
MySql.Data.MySqlClient.MySqlCommand:System.Data.ID bCommand.ExecuteReader
(CommandBehavior behavior)
in <0x00a22> System.Data.Common.DbDataAdapter:Update
(System.Data.DataRow[] dataRows, System.Data.Common.DataTableMapping

Did I forget to do something in my code? I thought I had defined the
parameters properly for each command. Any ideas?
David P. Donahue
Mar 31 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.