/// <summary>
/// 执行存储过程,Cnn数据库连接对象
/// </summary>
/// <param name="parameter">参数数组</param>
/// <param name="procudureName">存储过程名称</param>
public void excuPro(string procudureName,parameter [] proParameter)
{
SqlCommand cmd=new SqlCommand();
cmd.CommandType=System.Data.CommandType.StoredProcedure ;
cmd.CommandText=procudureName;
for(int i=0;i<parameter.Length;i++)
cmd.Parameters.Add(parameter[i]);
cmd.Connection=Cnn;
try
{
if(Cnn.State==System.Data.ConnectionState.Closed)
Cnn.Open();
return cmd.ExecuteReader();
}
catch(System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message );
}
finally
{
cmd.Dispose();
}
}
本文地址:http://com.8s8s.com/it/it44532.htm