SQLDMO connect code works in 2000, not in 2005

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.

LVL 67
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DBAduck - Ben MillerPrincipal ConsultantCommented:
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.
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Okay, thanks.  Do you have a SMO code snippet that accomplishes the above?
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DBAduck - Ben MillerPrincipal ConsultantCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.