I am designing a Form for data entry to a mysql database. Nothing fancy. This is my first time using c# to communicate with a mysql db. I get a very strange error in results.

Whenever I try to utilize a stored procedure call 'Insert_manacost_bridge_entry(pColor VARCHAR, pCost INT, pCard_ID INT)' I get the following result: The value passed in the pCost parameter is in place of the pColor field in the db record.

I attached the C# code and the mysql routine.

Testing done with weird results:

if I invoke the routine by performing a Call from the MySqlCommand as shown below and pass the params right there, the result is recorded correctly. If I uncomment the Params.Add(..) lines ... this is when pCost is in the place of pColor while pCost will be a 0 value in the db.




Code
MySqlCommand cmd2 = conn.CreateCommand();
Code
cmd2.CommandText = "call Insert_Manacost_Bridge_Entry('halp',2,2)";
Code
cmd2.CommandType = System.Data.CommandType.Text;
Code
//cmd2.Parameters.Add("pColor", MySqlDbType.VarChar).Value = "RED";
Code
//cmd2.Parameters.Add("pCost", MySqlDbType.Int32).Value = 1111;
Code
//cmd2.Parameters.Add("pCard_ID", MySqlDbType.Int32).Value = 14;
Code
//cmd2.ExecuteNonQuery();
Code
Code
CREATE DEFINER=`root`@`localhost` PROCEDURE `Insert_Manacost_Bridge_Entry`(pColor VARCHAR(4), pCost INT, pCard_ID INT)
Code
BEGIN
Code
        DECLARE card_mana_ID INT DEFAULT 0;
Code
	DECLARE manacost_ID INT DEFAULT 0;
Code
Code
	SET manacost_ID = ((SELECT COUNT(*) FROM manacost_entry) + 1);
Code
	SET card_mana_ID = ((SELECT COUNT(*) FROM bridge_card_manacost) + 1);
Code
        INSERT INTO manacost_entry (manacost_ID, Color, Cost)VALUES (manacost_ID, pColor, pCost);
Code
        INSERT INTO bridge_card_manacost (card_mana_ID, card_ID, manacost_ID) VALUES (card_mana_ID, pCard_ID, manacost_ID);
END