i am using mysql with .net framework 4.0 . i have stored procedures in my database. my stored procedure calling is:
public DataTable addProductMenu(int myid, string itemname)
{
MySqlConnection connection = new MySqlConnection(connectionString);
MySqlDataAdapter adapt = new MySqlDataAdapter("updateProductMenu", connection);
adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
adapt.SelectCommand.Parameters.AddWithValue("myid", myid);
adapt.SelectCommand.Parameters.AddWithValue("itemname", itemname);
DataTable dt = new DataTable();
adapt.Fill(dt);
adapt = null;
if (dt != null && dt.Rows.Count != 0)
{
return dt;
}
else
{
return null;
}
}
code is working when i use insert, select commands in database but not update. i tested my procedure in mysql query browser and its working fine.
Also tried this code for just update query
public DataTable updateProductMenu(int myid, string itemname)
{ //Veritabanından ürün menüsündeki başlığı güncelle
MySqlConnection cnx = new MySqlConnection(connectionString);
MySqlDataAdapter adapter = new MySqlDataAdapter();
string cmdText = "updateProductMenu";
MySqlCommand cmd = new MySqlCommand(cmdText, cnx);
cmd.CommandType = CommandType.StoredProcedure;
MySqlParameter param;
param = new MySqlParameter("?myid", MySqlDbType.Int32);
param.Value = myid;
param.Direction = ParameterDirection.Input;
cmd.Parameters.Add(param);
param = new MySqlParameter("?itemname", MySqlDbType.VarChar);
param.Value = itemname;
param.Direction = ParameterDirection.Input;
cmd.Parameters.Add(param);
adapter.SelectCommand = cmd;
DataTable dt = new DataTable();
adapter.Fill(dt);
adapter = null;
if (dt != null && dt.Rows.Count != 0)
{
return dt;
}
else
{
return null;
}
}
both have the error
Procedure or function '`updateProductMenu`' cannot be found in database '`mydatabase`'.
ADDED—————————————–
the user has all privileges. i checked again.
here is my connectionstring in web.config file…:
<add name="maktesConn" connectionString="Server = myserver; Port =3306; Database =mydatabase; Uid =mysqlsanatkar; Pwd =*123qsanatq*/;" />
…….and here is part of my class…..:
public class Mimages
{
private string connectionString;
public Mimages()
{
connectionString = ConfigurationManager.ConnectionStrings["maktesConn"].ToString();
}
and here is part of my stored procedure
DROP PROCEDURE IF EXISTS mydatabase.updateProductMenu $$
CREATE PROCEDURE mydatabase.updateProductMenu (myid INT, itemname VARCHAR(60))
BEGIN
....
Solved the problem…. mysql connector for .net was 6.3.7. i updated it to 6.4.4. Now all my stored procedures are working. Thanks for your reply “bang” btw.