public DataTable Select()
{
SqlConnection con = null;
try
{
con = new SqlConnection("Data Source=192.168.80.26;Initial CataLog=db_Dinner;UID=sa;Pwd=111111");
SqlCommand com = new SqlCommand("Procedure", con);
com.CommandText = "存储过程名";
SqlDataAdapter da = new SqlDataAdapter(com);
SqlParameter[] arr = {
new SqlParameter("@12","123"),
new SqlParameter("@31","123")
};//添加存储过程参数
com.Parameters.AddRange(arr);//将参数添加到存储过程中
DataTable dtb = new DataTable();
da.Fill(dtb);
if (dtb == null)
{
Console.WriteLine("Not Null");
}
return dtb;
}
catch (Exception)
{
throw;
}
finally
{
con.Close();
}
}