fill dataset/grid with multiple queries from multiple servers

  • Thread starter Thread starter Dave Edwards
  • Start date Start date
D

Dave Edwards

I understand that I can fill a datagrid with multiple queries, but I cannot
figure out how to fill a dataset with the same query but run against
multiple SQL servers, the query , table structure and username, password etc
will be exactly the same for each server, the only thing that will change is
the server name. Idealy I would like to get the server names from a seperate
dataset so there could be any number of servers, allthough in practice it
would be unlikely that there would be more than 3 servers.

Any Ideas, I'm a bit lost.
Cheers
Dave.
 
wouldnt u just have to pass it to a different connection then before u
execute the dataadapter ?
or just use the same connection itself but the data source portion of the
connection string would be referencing the server name as a variable that is
passed as a parameter ..
 
yup the + comes on when u dont specify the table.. its sorta like a cool
featue i guess.. hahaha.. for asp.net u get the first table immediately
cause they cant render those fancy stuff.. anyway.......

u got 2 ways..

datagrid1.datasource=ds.tables(0)
or
datagrid1.datasource=ds
datagrid1.datamember="TableName"


--
Regards,
Mike
http://bikesh.europe.webmatrixhosting.net
http://www.planetsourcecode.com (search keyword: phoetus)

Dave Edwards said:
Well I managed to pul something together myself in the end that works quite
well

Dim I As Integer
Dim dsXMLData As New DataSet
Dim DS As New DataSet

dsXMLData.ReadXml("serverlist.xml")

For I = 0 To dsXMLData.Tables(0).Rows.Count - 1
Dim connect As New SqlConnection("Integrated
Security=SSPI;database=database;server=" &
dsXMLData.Tables(0).Rows(I).Item(0))
connect.Open()
Dim command As String = "SELECT * form table"
Dim adaptor As SqlDataAdapter = New SqlDataAdapter(command, connect)
adaptor.Fill(DS)
DataGrid1.DataSource = DS
Next I

The onlt problem I have is that I now need to navigate through the datagrid
to get to the data. When the app first opens I get a + sign on the datagrid,
clicking that I get the word table and clicking that I get to the data, any
ideas how to get straight to the data?

Cheers
Charlie.

that
yup the + comes on when u dont specify the table.. its sorta like a cool
featue i guess.. hahaha.. for asp.net u get the first table immediately
cause they cant render those fancy stuff.. anyway.......

u got 2 ways..

datagrid1.datasource=ds.tables(0)
or
datagrid1.datasource=ds
datagrid1.datamember="TableName"
 
Well I managed to pul something together myself in the end that works quite
well

Dim I As Integer
Dim dsXMLData As New DataSet
Dim DS As New DataSet

dsXMLData.ReadXml("serverlist.xml")

For I = 0 To dsXMLData.Tables(0).Rows.Count - 1
Dim connect As New SqlConnection("Integrated
Security=SSPI;database=database;server=" &
dsXMLData.Tables(0).Rows(I).Item(0))
connect.Open()
Dim command As String = "SELECT * form table"
Dim adaptor As SqlDataAdapter = New SqlDataAdapter(command, connect)
adaptor.Fill(DS)
DataGrid1.DataSource = DS
Next I

The onlt problem I have is that I now need to navigate through the datagrid
to get to the data. When the app first opens I get a + sign on the datagrid,
clicking that I get the word table and clicking that I get to the data, any
ideas how to get straight to the data?

Cheers
Charlie.
 
Thanks Mike, that does the trick, i like this vb.net stuff. I'm learning
fast and getting things done.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top