在c#asp.net中调用的存储过程 [英] Stored procedure to called in c# asp.net

查看:65
本文介绍了在c#asp.net中调用的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我尝试下面的代码在数据库中插入数据..但是有错误存储无法找到存储过程''Allocate_call'' 。



在c#asp.net中定义存储过程的位置



非常感谢,



Hi,

I m a trying below code to insert data in database.. but there is error "Stored could not find stored procedure ''Allocate_call''".

Where to define stored procedure in c# asp.net

Thanks n regards,

protected void btnAllo_Click(object sender, EventArgs e)
    {
        string var_comp_no;
        string var_Tech_name;
        var_comp_no = ddlComplaint.SelectedValue;
        var_Tech_name=ddlAllow.SelectedValue;
        SqlCommand cmd_insert = new SqlCommand();
        SqlConnection con = new SqlConnection("SERVER=KSHITIJA-PC; Initial Catalog=CRM;Integrated Security=True");
        cmd_insert.Connection = con;

        cmd_insert.CommandType = CommandType.StoredProcedure;
        cmd_insert.CommandText = "Allocate_Call";

        cmd_insert.Parameters.Add(new SqlParameter("@comp_no", SqlDbType.Int));
        cmd_insert.Parameters["@comp_no"].Value = var_comp_no; ;

        cmd_insert.Parameters.Add(new SqlParameter("@Tech_name", SqlDbType.VarChar, 50));
        cmd_insert.Parameters["@Tech_name"].Value = var_Tech_name;

        try
        {
            con.Open();

            int i = cmd_insert.ExecuteNonQuery(); ;
            //int a = cmd1.ExecuteNonQuery();
            if (i == 1)
            {
                ddlComplaint.SelectedItem.Text = "";
                EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK");
                MsgBox1.Show("Message: ", "Call Assigned to Technician", null, mb);
            }

        }
        catch (Exception ex)
        {
            EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK");
            MsgBox1.Show("Error: ", ex.Message, null, mb);

        }
        finally
        {
            con.Close();
        }
    }

推荐答案

检查数据库中是否存在存储过程Allocate_call。
Check if the stored procedure Allocate_call exists on the database.


这篇关于在c#asp.net中调用的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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