public SqlDataReader 方法名()
{
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
SqlCommand cmd=new SqlCommand("存储过程名",conn);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@列名",参数);
conn.Open();
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
public void 方法名()
{
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
SqlCommand cmd=new SqlCommand("存储过程名",conn);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@列名",参数);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
public DataSet 方法名()
{
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
SqlDataAdapter da=new SqlDataAdapter("存储过程名",conn);
da.SelectCommand.CommandType=CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@列名",参数);
DataSet ds=new DataSet();
da.Fill(ds);
return ds;
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1038988