SQLDMO connect code works in 2000, not in 2005

Posted on 2008-11-18
Last Modified: 2012-05-05
Hi all

I have the below Access code snippet working for SQL 2000 servers, but not SQL 2005.  Does anyone have experience with this?

Dim oServer As SQLDMO.SQLServer
Set oServer = New SQLDMO.SQLServer

oServer.LoginSecure = True

'The below line works for 2000 servers, but produces a 'To connect to this server you must use SQL Server Management Studio or SQL Server Management Objects (SMO) errmsg for 2005 servers
oServer.Connect "SomeServerName"

Thanks in advance.

Question by:Jim Horn
    LVL 24

    Expert Comment

    by:DBAduck - Ben Miller
    Remember that usually SMO is backward compatible, but not forward compatible.  The code that you have is friendly to SQL 2000, but not 2005.  And in this case, you are using DMO which is replaced by SMO.  You need to have the SMO components in order to connect to some of the items in SQL 2005, so you need to get the 2005 SMO components and you should be good.  The other thing to remember is that SQL 2005 SMO will almost always work on SQL 2000.
    LVL 65

    Author Comment

    by:Jim Horn
    Okay, thanks.  Do you have a SMO code snippet that accomplishes the above?
    LVL 65

    Accepted Solution

    I have a working solution.

    In Access VBA code I'm able to determine if this is a 2000 vs. 2005 database.
    If 2000, I retain the original SQL-DMO code that works fine.
    If 2005, I use an ADODB.Connection to connect to that server's master db, then query the sys.databases view to get the list.

    Unless I see some SMO code that pulls this off, I'll request a PAQ-Refund in a couple of days.
    LVL 24

    Expert Comment

    by:DBAduck - Ben Miller
    The other side to SMO is that it is managed code, so it would be in the CLR space and not necessarily accessible from Access.  I believe that you could do it from Access 2007, but it would not be VBA.

    So you would be well off using DMO and then your ADODB if you are using Access and VBA.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now