Skip to content

How to call update stored procedure and select stored procedure?

Dinusha Gamage

Asked Apr 8, 2008, 2:00 AM EDT2 answers
Share
LinkedInX

Dear Friends,

How do you use Select stored procedure(to display data in the windows application) and Update stored procedure ( to update data through windows application UI)? I learnt Insert stored procedure from your replys.

Thanks in advance.........

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    how did you find the peace of code that I sent to you?
    0
  • 0

    Dear Friend,

    Thanks for that reply, and I run that coding which has given below........ But there is an error coming

    //Error : The SqlParameterCollection only accepts non-null SqlParameter type objects.
    Parameter name: value

    So, How do you provide the @Cust_code(this is the customer code you want to invoke from the table) in the Coding

    CREATE PROCEDURE usp_GetCustomer

    @Cust_code char(8)

    as

    SELECT cust_code, cust_name FROM CM_CUSTHED
    WHERE cust_code=@Cust_code

    GO

    // as above I defined the SQL S-procedure.

    And then write the code below :


    private void btnView_Click(object sender, EventArgs e)
    {
                SqlConnection s = new SqlConnection(connectionstring);
                s.Open();
                SqlCommand cmd = new SqlCommand("usp_GetCustomer", s);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter para = new    SqlParameter("@Cust_code",System.Data.SqlDbType.Char);

    //In the given below coding how do you provide the customer code to filter and dispaly it in the widows application???????????
                cmd.Parameters.Add(para.Value);
    }

    0