| re: Filling two datagrids from two SELECTS in one DataSet
You have to have 2 datatables in the dataset to do what you want
When you do this.[color=blue]
>MyCommand.Fill(DS, "pubs"[/color]
even if you have 2 queries ADO.NET will merge the result sets into one Datatable
So what you have to do is execute the fill command one at a time for each select queries that you have. Also use different table names in the Fill method call (i.e. "pubs1", "pubs2", etc)
Then bind the 2 datatables seperately to your datagrids
Suresh
----- DC Gringo wrote: ----
This code has two SELECT statements, each returning several records. I wan
to fill a dataset and then two datagrids. How would I fill the SECON
datagrid from this cod
----
Sub BindSQL(
Dim MyConnection As SqlConnectio
Dim DS as DataSe
Dim MyCommand As SqlDataAdapte
Dim RcdCount As Intege
'Our SQL strin
Dim sqlStr As String = "SELECT title FROM authors SELECT au_lname FRO
authors
'The connection to our databas
Dim strConn As String = "server=(local);uid=sa;pwd=;" &
"database=pubs;Trusted_Connection=yes;
Next we need to instantiate our connection and command object, and the fil
our DataSet object with the results of the SQL query
..
'Open up our connection with our connection objec
MyConnection = New SQLConnection(strConn
'To execute our Sql Statement and provide our active connectio
MyCommand = NewSqlDataAdapter(sqlStr, MyConnection
'Create instance of DataSet object and fill our predetermine
'datagrid with it and we name i
DS = new DataSet(
MyCommand.Fill(DS, "pubs"
--
____
DC |