Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 17th, 2003, 05:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: South Bend, Indiana, USA.
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default Test to see if a SQL Server exists

Is there a good way to test to see if a MS SQL Server actually exists?

I have an Access ADP and the user enters the name of their MS SQL server and I use that entry in my connection string, but if it is wrong my code bombs.

I might be able to trap for that error, but wanted to see if anyone else has a better solution.

Thanks.
__________________
Mitch
  #2 (permalink)  
Old July 18th, 2003, 04:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This may work:

Code:
Public Function TestSQLServer(strSQLServerName As String) As Boolean
Dim oApp As SQLDMO.Application
Dim objNames As NameList
Dim intCount As Integer

    Set oApp = New SQLDMO.Application
    Set objNames = oApp.ListAvailableSQLServers
    TestSQLServer = False

    If objNames.Count > 0 Then
        For intCount = 1 To objNames.Count
            If objNames.Item(intCount) = strSQLServerName Then
                TestSQLServer = True
            End If
        Next
    End If

End Function

Brian Skelton
Braxis Computer Services Ltd.
  #3 (permalink)  
Old July 18th, 2003, 04:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...

P.S. You'll need a reference to the Microsoft SQLDMO Object Library to get the above code to work!


Brian Skelton
Braxis Computer Services Ltd.


Similar Threads
Thread Thread Starter Forum Replies Last Post
What’s the .NET Way to test if Folder Exists? BrianWren Pro Visual Basic 2005 3 March 14th, 2007 08:35 AM
What’s the .NET Way to test if Folder Exists? BrianWren Visual Basic 2005 Basics 3 January 12th, 2007 07:32 PM
What’s the .NET Way to test if Folder Exists? BrianWren VB.NET 0 November 30th, 2006 02:46 PM
How to test if a column exists in a table jtrifts SQL Server 2000 2 February 16th, 2006 02:25 PM
howto test document exists folklayer XSLT 2 October 19th, 2005 05:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.