3
Answers

How to call a Stored Procedure?

Dinusha Gamage

Dinusha Gamage

16y
2.1k
1

Dear Friend,

I typed this code and run the application.......... But there is an error... Please help me to verify this problem.........

 private void btnSave_Click(object sender, EventArgs e)
        {
            string connectionstring = "Data Source=LOCALSERVER;Initial Catalog=ACME_ERP;Integrated Security=True ";
            SqlConnection s = new SqlConnection(connectionstring);

            SqlCommand cmd = new SqlCommand("usp_insertcustomer", s);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(@cust_code, this.cmdCustCode.Text);
            cmd.Parameters.Add(@cust_name, this.txtCustName.Text);

//(@cust_code and @cust_name are parameters defined in the sql procedure

            cmd.ExecuteReader();

        }


//Error 1 The name 'cust_code' does not exist in the current

Answers (3)