By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,770 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

fill dataset/grid with multiple queries from multiple servers

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
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.

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004
Nov 20 '05 #2

P: n/a
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.

"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
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.

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004

Nov 20 '05 #3

P: n/a
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" <no**@none.com> wrote in message
news:hU************@newsfe2-gui.ntli.net...
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.

"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
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.

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004


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" <no**@none.com> wrote in message
news:hU************@newsfe2-gui.ntli.net... 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.

"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
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.

---
Outgoing mail is certified Virus Free. (well i'd like to think it is.. )
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004


Nov 20 '05 #4

P: n/a
Thanks Mike, that does the trick, i like this vb.net stuff. I'm learning
fast and getting things done.
"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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" <no**@none.com> wrote in message
news:hU************@newsfe2-gui.ntli.net...
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.

"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
> 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.
>
>
---
Outgoing mail is certified Virus Free. (well i'd like to think it
is.. ) Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004


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" <no**@none.com> wrote in message
news:hU************@newsfe2-gui.ntli.net...
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.

"Mike Smith" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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 ..

"Dave Edwards" <no**@none.com> wrote in message
news:7p**************@newsfe2-gui.ntli.net...
> 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.
>
>
---
Outgoing mail is certified Virus Free. (well i'd like to think it

is.. ) Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/2004



Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.