Put this function in your static data access (dal) class. This function get a SQL query as parameter and return DataTable with data from the database. Note if the connection is close before Fill was call it is opened to retrieve data and then closed. If the connection is open before Fill is called then it will remain open.
Instructions: Put this function in your static data access (dal) class.
public static DataTable GetDataTableNoParameters(string Query)
string myConnectionString = WebConfigurationManager.ConnectionStrings["Connection_Name"].ConnectionString;
SqlConnection oSqlConnection = new SqlConnection(myConnectionString);
SqlCommand cmd = new SqlCommand(Query, oSqlConnection);
SqlDataAdapter oSqlDataAdapter = new SqlDataAdapter(cmd);
DataTable DataTable_To_Fill = new DataTable();
}// end function