Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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,

C#
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();
        }
    }
Posted
Updated 3-Jan-13 19:49pm
v2
Comments
bbirajdar 4-Jan-13 1:44am    
Error message is clear.. No need to tell you more
Sergey Alexandrovich Kryukov 4-Jan-13 1:47am    
How is this related to ASP.NET? Remove the tag "ASP.NET", add "ADO.NET".
—SA

1 solution

Check if the stored procedure Allocate_call exists on the database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900