How to execute a stored procedure within C# program

前端 未结 13 1654
别跟我提以往
别跟我提以往 2020-11-22 00:10

I want to execute this stored procedure from a C# program.

I have written the following stored procedure in a SqlServer query window and saved it as stored1:

<
13条回答
  •  迷失自我
    2020-11-22 00:14

    Calling Store Procedure in C#

        SqlCommand cmd = new SqlCommand("StoreProcedureName",con);
        cmd.CommandType=CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@value",txtValue.Text);
        con.Open();
        int rowAffected=cmd.ExecuteNonQuery();
        con.Close();
    

提交回复
热议问题