pillmill
asked on
Parameter 'ID' not found in the collection.
I get this error when I execute the command:
cmd.Parameters["ID"].Value = row["USER"];
where cmd is a MySqCommand and row is an element of a
XMLDoc.DataSet.Table
I thought "collection" referred to the table.
But I find the element in BOTH the cmd and in
the Table. How can I debug this?
cmd.Parameters["ID"].Value
where cmd is a MySqCommand and row is an element of a
XMLDoc.DataSet.Table
I thought "collection" referred to the table.
But I find the element in BOTH the cmd and in
the Table. How can I debug this?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
First of all do you try to run SQL query or storage procedure?
for storage procedure set:
cmd.CommandType = CommandType.StoredProcedur e;
Then you can try to add parameter:
cmd.Parameters.Add("@ID", row["USER"]);
or
cmd.Parameters.Add("?ID", row["USER"]);
for storage procedure set:
cmd.CommandType = CommandType.StoredProcedur
Then you can try to add parameter:
cmd.Parameters.Add("@ID", row["USER"]);
or
cmd.Parameters.Add("?ID", row["USER"]);
ASKER
The first parameter was ID and second email, added as:
cmd.Parameters.Add(new MySqlParameter("ID", MySqlDbType.Int32))
cmd.Parameters.Add(new MySqlParameter("email", MySqlDbType.String))
The assignment of the values of the parameters was done incorrectly as:
cmd.Parameters[0].Value = email;
When I changed the order, the error seemed to be corrected.
The error message didn't seem very informative though.