[AccessD] SQL Server not found

Gustav Brock Gustav at cactus.dk
Sun Oct 4 03:39:16 CDT 2009


Hi Doug

You could try this simple method:

Dim dbs As DAO.Database
Dim qry As DAO.QueryDef

On Error Resume Next
Set dbs = CurrentDb
Set qry = dbs.CreateQueryDef(vbNullString)
qry.Connect = strConnect  ' Your connect string for this SQL Server.
qry.ReturnsRecords = False
' Execute some valid SQL statement.
qry.SQL = "SELECT * FROM SomeTable"
qry.Execute dbSeeChanges
If Err <> 0 Then
    MsgBox "No connection to database server."
End If

/gustav

> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Steele
> Sent: Saturday, October 03, 2009 2:53 PM
> To: accessd at databaseadvisors.com 
> Subject: [AccessD] SQL Server not found
>
> Hello all:
>
> I have an Access front end with a SQL Server express back
> end.  Occasionally the SQL Server isn't available.  I'd like
> the Access db to exit quickly and gracefully when this
> happens.  However, it takes about two minutes for the initial
> query to SQL server to fail and it fails with a screen asking
> the user to fill in the Server name.  Is there a quick way to
> find out if the server is available before I try to query it
> and to avoid getting the failure screens?
>
> Thanks,
> Doug Steele






More information about the AccessD mailing list