Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 873
  • Last Modified:

Excel 2003 connects to SQL2000 using DSN - Changing server

Hi!

Current situation:

We have a number of Microsoft Excel 2003 workbooks on Windows XP that connect to a Windows 2000 server running SQL 2000 which use a system DSN to connect. We are upgrading to a new server (Windows 2008 Server running SQL2005)

What is the best way to get the Excel workbooks to connect to the new server? I have read quite a bit about this on the net and it seems that just changing the DSN information will not achieve this as connection information is imbedded in the Excel workbooks. I have found this:

How to change connection information for a query in Excel

Is this the right answer? Anything else I should be aware of? Is there an easier way? What are the best practices?

Thanks in advance

Cheers!
Steve
0
hal8999
Asked:
hal8999
  • 4
  • 2
1 Solution
 
philip m o'brienCommented:
Steve,
There should be no problem with you changing the DSN and effecting the update across the board provided the following points are adhered to:
The new source should have :
 - the same DSN
 - the same Description
 - the same UID & PW i.e. whatever is valid on the old source should be valid on the new
The old source should be deleted (or renamed until all is confirmed as working) from the System DSN lists
This is the standard method I use when various clients have changed servers. Except once, where the table structure was changed by their IT team without telling anyone, I have never had any issues this way.
Assuming that the queries are linked by DSN name, whether as a workbook query or via VBA macros, all should be good.
Have you already tried this method?
Regards
0
 
hal8999Author Commented:
Hi. Many thanks for your reply

I have not tried this method yet but will do so when I am on-site during this week. I will keep you posted but my initial thoughts seems to think that this'll work

Fingers crossed!
0
 
philip m o'brienCommented:
Keeping fingers crossed for you. If not just let me know and I will set up a dummy server just to test.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hal8999Author Commented:
Ok...

I tried what you suggested and it worked fine. However, I copied some workbooks to a clean XP machine that had no
DSN set-up whatsoever, opened a workbook and refreshed the data. It connected fine..!

I then opened the workbook in Notepad++ and searched for the server name and lo and behold, I found the following buried in the workbook:

DRIVER=SQL Server;SERVER=OLDSERVER2K;UID=USER;PWD=PASSWORD;APP=Microsoft Open Database Connectivity;WSID=CT_8;QueryLogTime=Yes

I had read that this info was 'hard coded' into Excel workbooks and found the following code:


This seems to work but do I really have to run this on every workbook?

It appears that once an Excel workbook is created with an ODBC link, the ODBC link is no longer needed and the workbook can be passed around to whomever. However, if there is a system DSN, the method described above will work as well

I've got some more experimenting to do...auurrgg!!



Sub ChangeConn

Dim qt As QueryTable
Dim wsh As Worksheet
Dim NewLoc As String
Dim LiveLoc As String

NewLoc = "NEWSERVER2K8"
LiveLoc = "OLDSERVER2K"

For Each wsh in ThisWorkbook.Worksheets
    For Each qt in wsh.QueryTables
        If InStr(1, qt.connection, NewLoc) > 0 Then
            qt.Connection = Replace(qt.Connection, NewLoc, LiveLoc)
        Else
            qt.Connection = Replace(qt.Connection, LiveLoc, NewLoc)
        End If
        
        qt.Refresh
    Next qt
Next wsh

End Sub

Open in new window

0
 
hal8999Author Commented:
The only way to do what I needed was from this free Excel Add-in:

http://vangelder.orconhosting.net.nz/excel/queryeditor.html

Running the above code does fix some workbooks...but not others and I had to run this add-in and manually correct the connection string(s) for each worksheet

Thanks for any help!
0
 
hal8999Author Commented:
Answered by OP
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now