MSSQL C# 呼叫 SP 後丟資料到 datatable
using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString.ToString()))
{
try
{
DataTable table = new DataTable();
connection.Open();
sqlstring = @"exec [放SP] [放SP的參數]";
SqlCommand cmd = new SqlCommand(sqlstring, connection);
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
da.Fill(dt);
}
connection.Close();
DataTable dt2 = table;
}
catch (Exception e)
{
string x = e.Message;
}
}