忘了咋调用存储过程,嘿嘿,记录下msdn的案例
using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; public partial class StoredProcedures { [SqlProcedure()] public static void InsertCurrency_CS( SqlString currencyCode, SqlString name) { using (SqlConnection conn = new SqlConnection("context connection=true")) { SqlCommand InsertCurrencyCommand = new SqlCommand(); SqlParameter currencyCodeParam = new SqlParameter("@CurrencyCode", SqlDbType.NVarChar); SqlParameter nameParam = new SqlParameter("@Name", SqlDbType.NVarChar); currencyCodeParam.Value = currencyCode; nameParam.Value = name; InsertCurrencyCommand.Parameters.Add(currencyCodeParam); InsertCurrencyCommand.Parameters.Add(nameParam); InsertCurrencyCommand.CommandText = "INSERT Sales.Currency (CurrencyCode, Name, ModifiedDate)" + " VALUES(@CurrencyCode, @Name, GetDate())"; InsertCurrencyCommand.Connection = conn; conn.Open(); InsertCurrencyCommand.ExecuteNonQuery(); conn.Close(); } } }
本文转自today4king博客园博客,原文链接:http://www.cnblogs.com/jinzhao/archive/2009/02/23/1396706.html,如需转载请自行联系原作者