public static DataTable ExecuteDataTable(string storedProcedureName,params SqlParameter[] arrParam) { DataTable dt = new DataTable(); // Open the connection using (SqlConnection cnn = new SqlConnection("connectionString")) { cnn.Open(); // Define the command using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = cnn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = storedProcedureName; // Handle the parameters if (arrParam != null) { foreach (SqlParameter param in arrParam) cmd.Parameters.Add(param); } // Define the data adapter and fill the dataset using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } } } return dt; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)