开发者

mysql .net update stored procedure cannot be found

开发者 https://www.devze.com 2023-04-08 00:50 出处:网络
i am using mysql with .net framework 4.0 . i have stored procedures in my database. my stored procedure calling is:

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 checke开发者_StackOverflowd 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
....


Are you saying that you are able to call other stored procedures with the same code or just select and insert commands ?

Have you checked caps on both database name and stored procedure name? Depending on settings MySql will convert names to lower case and become case sensitive.

Checked security for db current ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消