I've weird problem with stored procedure in Data Access Layer. Stored Procedure which is used in Data Access Layer is unable to recognize stored procedure in MySQl. When I replace stored procedure with Insert statement it is working good.
Hi Thanks a lot you really saved my day, Well I had a problem with the database name in web.config. I've kept Captials in database name in web.config. When I removed it. It worked like a charm... Anyway Thanks once again. Have a great day!!!
karipe.nares...
Member
24 Points
54 Posts
Problem with stored procedure in Data Access Layer
Dec 12, 2012 03:42 PM|LINK
Hi All,
I've weird problem with stored procedure in Data Access Layer. Stored Procedure which is used in Data Access Layer is unable to recognize stored procedure in MySQl. When I replace stored procedure with Insert statement it is working good.
Please find code below for reference.
try { con.Open(); MySqlCommand cmd = new MySqlCommand("InsertUsers", con); cmd.Parameters.Add(new MySqlParameter("?p_FirstName", FirstName)); cmd.Parameters.Add(new MySqlParameter("?p_LastName", LastName)); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } catch (MySqlException ex) { string msg = "Insert Error:"; msg += ex.Message; throw new Exception(msg); } finally { con.Close(); }Insert Error:Procedure or function '`InsertUsers`' cannot be found in database '`UsersDB`'.
Dr. Acula
Participant
1441 Points
319 Posts
Re: Problem with stored procedure in Data Access Layer
Dec 12, 2012 03:47 PM|LINK
you need to tell the cmd object it is a stored procedure
karipe.nares...
Member
24 Points
54 Posts
Re: Problem with stored procedure in Data Access Layer
Dec 12, 2012 04:35 PM|LINK
Hi Acula, Thanks for your response. That I already mentioned in my code...
oned_gk
All-Star
31661 Points
6473 Posts
Re: Problem with stored procedure in Data Access Layer
Dec 13, 2012 05:38 AM|LINK
Check the CASE of table name, stored procedure name etc, maybe mysql is case sensitive.
karipe.nares...
Member
24 Points
54 Posts
Re: Problem with stored procedure in Data Access Layer
Dec 13, 2012 06:11 AM|LINK
Hi Thanks a lot you really saved my day, Well I had a problem with the database name in web.config. I've kept Captials in database name in web.config. When I removed it. It worked like a charm... Anyway Thanks once again. Have a great day!!!
oned_gk
All-Star
31661 Points
6473 Posts
Re: Problem with stored procedure in Data Access Layer
Dec 13, 2012 06:51 AM|LINK
I never use mysql, i just try analyst your problem. I look to your code is fine, and you said Insert statement working good