SqlCommand cmd =new SqlCommand("存储过程的名字",connstr);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter[] paraters = new SqlParameter[] {
new SqlParameter("@学号",SqlDbType.Int),
new SqlParameter("@姓名",SqlDbType.NVarChar),
};
paraters[0].Value = 1;
paraters[1].Value = "222";
foreach (SqlParameter par in paraters)
{
cmd.Parameters.Add(par);
}
两种方式读取;
1.SqlDataReader reader = cmd.ExecuteReader();
2.SqlDataAdapter adapter = new SqlDataAdapter(cmd);