Solved

Excel 2003 connects to SQL2000 using DSN - Changing server

Posted on 2011-02-18
7
868 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Industry Leaders: 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!

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

628 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