C# 之行存储过程操作数据库演示
public void LogRequest(string requestor, string messageBody) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("wp_InsertRequest", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("Requestor", requestor)); cmd.Parameters.Add(new SqlParameter("EmailBody", messageBody)); cmd.ExecuteNonQuery(); } }