Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel 2003 connects to SQL2000 using DSN - Changing server

Posted on 2011-02-18
7
Medium Priority
?
871 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
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.

 

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

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.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

721 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