Solved

Excel 2003 connects to SQL2000 using DSN - Changing server

Posted on 2011-02-18
7
862 Views
Last Modified: 2012-05-11
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
Comment
Question by:hal8999
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:philip m o'brien
ID: 34932648
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
 

Author Comment

by:hal8999
ID: 34942716
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
 
LVL 7

Expert Comment

by:philip m o'brien
ID: 34944493
Keeping fingers crossed for you. If not just let me know and I will set up a dummy server just to test.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:hal8999
ID: 35027117
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
 

Accepted Solution

by:
hal8999 earned 0 total points
ID: 35324692
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
 

Author Closing Comment

by:hal8999
ID: 35360821
Answered by OP
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question