Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static DataTable SelectRecordsFromTable(Table tableName)
- {
- string connectionStringToDatabase = BuildConnectionString();
- SqlConnection sqlConnection = new SqlConnection(connectionStringToDatabase);
- sqlConnection.Open();
- string sqlExpression = String.Format("SELECT * FROM {0}", Convert.ToString(tableName));
- SqlCommand sqlCommand = new SqlCommand();
- sqlCommand.Connection = sqlConnection;
- sqlCommand.CommandText = sqlExpression;
- SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
- DataSet dataSet = new DataSet();
- sqlDataAdapter.Fill(dataSet);
- DataTable records = dataSet.Tables[0];
- sqlConnection.Close();
- return records;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement