1

I got the following error while calling a stored procedure in asp.net c#page. I could not understand the error details. Please help me to solve this.

MySqlCommand cmd =
    new MySqlCommand("CALL sp_wrt_test(10, @param);SELECT @param", connection);

cmd.CommandTimeout = 5000000;

//Assign the query using CommandType7
using (IDataReader reader = cmd.ExecuteReader())
{
    if (reader.Read())
        id = "@param = " + reader[0];
}


create procedure sp_wrt_test(in name varchar(100), out retval varchar(200))
begin
 insert into hd_test(fld_name) values(name);
 select max(fld_id)into retval from hd_test;
end;
user3085540
  • 275
  • 3
  • 12
  • 27
  • You never declare `@param` what is it? An output variable? Even so you still need to add it to the command. Please post the exact error message you are getting. Also Grant is right, the CALL then SELECT looks odd. – Evan L Mar 08 '14 at 04:49
  • http://www.devart.com/dotconnect/mysql/docs/Parameters.html Look this. – user3085540 Mar 08 '14 at 04:51
  • OK please post the error message *and* the code for your stored procedure. – Evan L Mar 08 '14 at 04:54
  • The above question is my error. Please see my edited post for procedure. – user3085540 Mar 08 '14 at 04:58
  • I don't see an error message, and you seem to be calling MySqlCommand before it has it's @param value. Also, I don't understand the second part of your call - SELECT @param". Are you looking for retval? – BarryDevSF Mar 08 '14 at 05:19
  • Now i change my code like this. MySqlCommand cmd = new MySqlCommand("CALL sp_wrt_test(?val, @param);", connection); cmd.Parameters.AddWithValue("?val", "admbsa1"); cmd.Parameters.Add(new MySqlParameter("@param", SqlDbType.VarChar)); cmd.ExecuteNonQuery(); string t_return = cmd.Parameters["@param"].Value.ToString(); – user3085540 Mar 08 '14 at 05:26
  • I got an another error OUT or INOUT argument 2 for routine sp_wrt_test is not a variable or NEW pseudo-variable in BEFORE trigger – user3085540 Mar 08 '14 at 05:27

0 Answers0