public static class Read { private static SqlConnection DataConnection; private static SqlDataAdapter DataAdapter; private static SqlCommand DataCommand; private static DataTable objDataTable; static Read() { DataConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["testDB"].ConnectionString); DataCommand = new SqlCommand(); objDataTable = new DataTable(); DataAdapter = new SqlDataAdapter(); DataCommand.Connection = DataConnection; DataAdapter.SelectCommand = DataCommand; } public static DataTable GetBranchesOfRestaurant(int RestaurantId, out string Error) { Error = string.Empty; objDataTable.Clear(); objDataTable = new DataTable(); DataCommand.CommandText = "GetBranchesOfRestaurant"; DataCommand.Parameters.AddWithValue("@RestaurantId", RestaurantId); DataCommand.CommandType = CommandType.StoredProcedure; try { if (DataConnection.State != ConnectionState.Open) DataConnection.Open(); DataAdapter.Fill(objDataTable); } catch (Exception ex) { Error = ex.Message; } finally { DataCommand.Parameters.Clear(); DataConnection.Close(); } return objDataTable; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)