访问程序时出现问题 [英] Problem While accessing Procedure

查看:78
本文介绍了访问程序时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这是我的C#代码,用于访问Procedure

Hi
Here Is my c# code to access Procedure

private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(StrCon);
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataReader dr;
            cmd.CommandText = "Taxes";**Error::Procedure or function '`Taxes`' cannot be found in database ''
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;

            con.Open();
            dr = cmd.ExecuteReader();
            dr.read()
            MessageBox.Show(dr[0].ToString());//Only for checking ID
            con.Close();
        }


这是程序


And here is the procedure

Create Procedure Taxes()
Begin
   Select ID from Tax;
End


但是,当我单击按钮时,我无法访问该过程
*显示我得到的实际错误.
我的代码中有任何愚蠢的错误.请让我知道.

谢谢
Swapnil


But when i click on button i am not able to access that procedure
* Show the actual error i got.
Is there any silly mistake in my code.Please Let me know.

thanks
Swapnil

推荐答案

//尝试使用此

//try to use this

create proc taxes
as
begin
select ID from Tax;
end




如您的代码所示,它应该可以正常工作.

如果不是这样的话
您需要先检查执行存储过程的数据库,

然后检查;与应用程序建立连接的数据库.
Hi,

As your code shows it should work properly.

If it''s not then;
You need to check the database first where you have executed your stored procedure,

And then check; to which database you have made connectivity of your application.


使用类似dbo.taxes的名称创建sp
use the name like this dbo.taxes to create the sp


这篇关于访问程序时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆