Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Changing Data Source

I'm new to using excel at a presentation tool for data
stored in a SQL Server database. I set up a data source
locally on my development machine between my development
SQL Server and Excel. Everything works fine and I am able
to make my graphs, etc. Now I'd like to distribute the
Excel workbook to management and change the data source to
look at the production SQL Server. I can edit the query,
but I can't get to anything that allows me to point to a
different data source, change users for security purposes,
passwords or databases. There has to be something there
I'm just not seeing. I can't imaging having to recreate
every Excel file just because the server gets renamed, add
or change users, etc. Thanks for taking your time to
answering my question.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Changing Data Source


in the querytable's output range
rightclick,

select
Edit Query

via VBA here's a rough beginning..

Sub tst()

Dim qt As QueryTable
Dim sNew As String


For Each qt In ActiveSheet.QueryTables
sNew = InputBox("Edit the string:", , qt.Connection)
If sNew < "" And sNew < qt.Connection Then
qt.Connection = sNew
End If

Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm new to using excel at a presentation tool for data
stored in a SQL Server database. I set up a data source
locally on my development machine between my development
SQL Server and Excel. Everything works fine and I am able
to make my graphs, etc. Now I'd like to distribute the
Excel workbook to management and change the data source to
look at the production SQL Server. I can edit the query,
but I can't get to anything that allows me to point to a
different data source, change users for security purposes,
passwords or databases. There has to be something there
I'm just not seeing. I can't imaging having to recreate
every Excel file just because the server gets renamed, add
or change users, etc. Thanks for taking your time to
answering my question.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Changing Data Source

Thanks for the reply. I've been though every part of the
Edit Query wizard and options. There is nothing there to
edit my connection string. But that is OK because VBA will
be faster than a GUI anyway.

Now I've got some questions about the VBA code. I modified
your code to simply view the existing connection string.

Public Function ConnectionString()

Dim qt As QueryTable

For Each qt In ActiveSheet.QueryTables
Debug.Print qt.Connection
Next

End Function

Results:
ODBC;DRIVER=SQL
Server;SERVER=DAVE;UID=sa;PWD=********;APP=Microso ft®
Query;WSID=DAVE;DATABASE=Agr

First off, I notice this is using ODBC. I thought that was
old stuff. I'm using Office 2000 - which is old as it is.
I'm use to using OLE DB: PROVIDER=SQLOLEDB.1;DATA
SOURCE=DAVE;INITIAL CATALOG=Agr;USER ID=sa;PASSWORD=*****

Secondly, in the code I notice you are using ActiveSheet
and then looping through each QueryTables. I have multiple
sheets. How can I loop through each of my sheets. I need
something like Excel.Sheet1.SetFocus, but nothing like
that exists. Again sorry, I am new to Excel programming.
I'm use to programming in Access and VB and haven't yet
figured out the whole heirarchy to the Excel object model.

-----Original Message-----

in the querytable's output range
rightclick,

select
Edit Query

via VBA here's a rough beginning..

Sub tst()

Dim qt As QueryTable
Dim sNew As String


For Each qt In ActiveSheet.QueryTables
sNew = InputBox("Edit the string:", , qt.Connection)
If sNew < "" And sNew < qt.Connection Then
qt.Connection = sNew
End If

Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm new to using excel at a presentation tool for data
stored in a SQL Server database. I set up a data source
locally on my development machine between my

development
SQL Server and Excel. Everything works fine and I am

able
to make my graphs, etc. Now I'd like to distribute the
Excel workbook to management and change the data source

to
look at the production SQL Server. I can edit the

query,
but I can't get to anything that allows me to point to

a
different data source, change users for security

purposes,
passwords or databases. There has to be something there
I'm just not seeing. I can't imaging having to recreate
every Excel file just because the server gets renamed,

add
or change users, etc. Thanks for taking your time to
answering my question.


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Changing Data Source


the basic hierarchy is in vba help
excel relies heavily on simple collections
what you're looking for is
workbooks
worksheets
cells (or range)


else just use help to highlight querytables..
follow help hyperlinks for applies to
or review the locals window on a breakpoint


dim wb as workbook
dim ws as worksheet
dim qt as querytable

For each wb in workbooks
for each ws in wb.worksheets
for each qt in ws.querytables
stop 'open local windows and review the variables
next
next
next

'---
re queries:
connections can be saved as as udl. (uniform data locator)
these can be easily edited as they are simple xml's


queries can be saves as odc files
(xml containing all query properties)

while you're queries show ODBC, Excel can just as easily handle ADO,
that just depends at what datasource (and DRIVER!!!) you select when you
create it.

hmm... you've got a bit of reading to do :)





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

Thanks for the reply. I've been though every part of the
Edit Query wizard and options. There is nothing there to
edit my connection string. But that is OK because VBA will
be faster than a GUI anyway.

Now I've got some questions about the VBA code. I modified
your code to simply view the existing connection string.

Public Function ConnectionString()

Dim qt As QueryTable

For Each qt In ActiveSheet.QueryTables
Debug.Print qt.Connection
Next

End Function

Results:
ODBC;DRIVER=SQL
Server;SERVER=DAVE;UID=sa;PWD=********;APP=Microso ft®
Query;WSID=DAVE;DATABASE=Agr

First off, I notice this is using ODBC. I thought that was
old stuff. I'm using Office 2000 - which is old as it is.
I'm use to using OLE DB: PROVIDER=SQLOLEDB.1;DATA
SOURCE=DAVE;INITIAL CATALOG=Agr;USER ID=sa;PASSWORD=*****

Secondly, in the code I notice you are using ActiveSheet
and then looping through each QueryTables. I have multiple
sheets. How can I loop through each of my sheets. I need
something like Excel.Sheet1.SetFocus, but nothing like
that exists. Again sorry, I am new to Excel programming.
I'm use to programming in Access and VB and haven't yet
figured out the whole heirarchy to the Excel object model.

-----Original Message-----

in the querytable's output range rightclick,

select
Edit Query

via VBA here's a rough beginning..

Sub tst()

Dim qt As QueryTable
Dim sNew As String


For Each qt In ActiveSheet.QueryTables
sNew = InputBox("Edit the string:", , qt.Connection)
If sNew < "" And sNew < qt.Connection Then
qt.Connection = sNew
End If

Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm new to using excel at a presentation tool for data
stored in a SQL Server database. I set up a data source locally on
my development machine between my development SQL Server and Excel.
Everything works fine and I am able to make my graphs, etc. Now I'd
like to distribute the Excel workbook to management and change the
data source to look at the production SQL Server. I can edit the
query, but I can't get to anything that allows me to point to a
different data source, change users for security purposes,
passwords or databases. There has to be something there I'm just not
seeing. I can't imaging having to recreate every Excel file just
because the server gets renamed, add or change users, etc. Thanks
for taking your time to answering my question.


.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Changing Data Source

Thanks! That helps me out. I was looking for Sheets not
Worksheets. And yes, I have a bit of reading and exploring
to do in this new model. Thanks again.

-----Original Message-----

the basic hierarchy is in vba help
excel relies heavily on simple collections
what you're looking for is
workbooks
worksheets
cells (or range)


else just use help to highlight querytables..
follow help hyperlinks for applies to
or review the locals window on a breakpoint


dim wb as workbook
dim ws as worksheet
dim qt as querytable

For each wb in workbooks
for each ws in wb.worksheets
for each qt in ws.querytables
stop 'open local windows and review the variables
next
next
next

'---
re queries:
connections can be saved as as udl. (uniform data locator)
these can be easily edited as they are simple xml's


queries can be saves as odc files
(xml containing all query properties)

while you're queries show ODBC, Excel can just as easily

handle ADO,
that just depends at what datasource (and DRIVER!!!) you

select when you
create it.

hmm... you've got a bit of reading to do :)





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

Thanks for the reply. I've been though every part of

the
Edit Query wizard and options. There is nothing there

to
edit my connection string. But that is OK because VBA

will
be faster than a GUI anyway.

Now I've got some questions about the VBA code. I

modified
your code to simply view the existing connection string.

Public Function ConnectionString()

Dim qt As QueryTable

For Each qt In ActiveSheet.QueryTables
Debug.Print qt.Connection
Next

End Function

Results:
ODBC;DRIVER=SQL
Server;SERVER=DAVE;UID=sa;PWD=********;APP=Microso ft®
Query;WSID=DAVE;DATABASE=Agr

First off, I notice this is using ODBC. I thought that

was
old stuff. I'm using Office 2000 - which is old as it

is.
I'm use to using OLE DB: PROVIDER=SQLOLEDB.1;DATA
SOURCE=DAVE;INITIAL CATALOG=Agr;USER

ID=sa;PASSWORD=*****

Secondly, in the code I notice you are using

ActiveSheet
and then looping through each QueryTables. I have

multiple
sheets. How can I loop through each of my sheets. I

need
something like Excel.Sheet1.SetFocus, but nothing like
that exists. Again sorry, I am new to Excel

programming.
I'm use to programming in Access and VB and haven't yet
figured out the whole heirarchy to the Excel object

model.

-----Original Message-----

in the querytable's output range rightclick,

select
Edit Query

via VBA here's a rough beginning..

Sub tst()

Dim qt As QueryTable
Dim sNew As String


For Each qt In ActiveSheet.QueryTables
sNew = InputBox("Edit the string:", , qt.Connection)
If sNew < "" And sNew < qt.Connection Then
qt.Connection = sNew
End If

Next
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm new to using excel at a presentation tool for

data
stored in a SQL Server database. I set up a data

source locally on
my development machine between my development SQL

Server and Excel.
Everything works fine and I am able to make my

graphs, etc. Now I'd
like to distribute the Excel workbook to management

and change the
data source to look at the production SQL Server. I

can edit the
query, but I can't get to anything that allows me to

point to a
different data source, change users for security

purposes,
passwords or databases. There has to be something

there I'm just not
seeing. I can't imaging having to recreate every

Excel file just
because the server gets renamed, add or change

users, etc. Thanks
for taking your time to answering my question.


.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Source Data using V-lookup Kevin Excel Worksheet Functions 2 April 14th 10 08:14 PM
Changing Data Source nathan_savidge Excel Worksheet Functions 1 July 17th 08 05:53 PM
Changing data source in a pivot John R Excel Discussion (Misc queries) 4 October 18th 07 08:09 PM
Changing query data source TonyL Excel Discussion (Misc queries) 1 July 4th 07 04:44 PM
Changing Data Source Driver S Taylor Excel Programming 1 October 15th 03 03:04 PM


All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"