G
Guest
I am wondering if someone could provide a code sample (or just a suggested
approach) on how to fill a single DataGridView with multiple result sets. For
example, this statement returns a one-line result set for each table in the
database:
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
It would be handy to be able to put them all into one DataGridView. I would
like to be able to handle an arbitrary SQL statement; above is just one
example. The code I am currently using is:
----------------------------------------------
DataTable dataTable = new DataTable();
SqlDataAdapter aviAdapter = new SqlDataAdapter(query, connection);
aviAdapter.Fill(dataTable);
aviDataTableBindingSource.DataSource = dataTable;
aviDataTableBindingSource.DataMember = null;
aviDataGridView.DataSource = aviDataTableBindingSource;
approach) on how to fill a single DataGridView with multiple result sets. For
example, this statement returns a one-line result set for each table in the
database:
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
It would be handy to be able to put them all into one DataGridView. I would
like to be able to handle an arbitrary SQL statement; above is just one
example. The code I am currently using is:
----------------------------------------------
DataTable dataTable = new DataTable();
SqlDataAdapter aviAdapter = new SqlDataAdapter(query, connection);
aviAdapter.Fill(dataTable);
aviDataTableBindingSource.DataSource = dataTable;
aviDataTableBindingSource.DataMember = null;
aviDataGridView.DataSource = aviDataTableBindingSource;