How to execute a stored procedure within C# program

前端 未结 13 1852
别跟我提以往
别跟我提以往 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:25

    using (var conn = new SqlConnection(connectionString))
    using (var command = new SqlCommand("ProcedureName", conn) { 
                               CommandType = CommandType.StoredProcedure }) {
       conn.Open();
       command.ExecuteNonQuery();
    }
    

提交回复
热议问题