Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

avoid adp to connect SQL server during sturtup

18 views
Skip to first unread message

Michael Gesser

unread,
Mar 6, 2003, 4:57:57 AM3/6/03
to
During loading Access Data Project (adp) it is automatically connecting
to the SQL Server specified in the File|Connection dialog.
Can I avoid that connecting (during loading)? My problem that I cannot
specify server
name in advance. (after adp is loaded I change server name from my
application).

Thanks in advance.
Michael

Uwe Ricken

unread,
Mar 6, 2003, 8:19:25 AM3/6/03
to
Hallo Michael,

We work with udl-files and a disconnected adp which connects
to the sql-server on startup.

Here is the code for the "auto connect" ;-)

Public Function ReConnectToSQLServer
Private const cUDLFile As String = "MyConnection.udl"

Set cnn = CreateObject("ADODB.Connection")
SysCmd acSysCmdSetStatus, "Connection to SQL-Server..."

' Get the path of the application
' UDL-File must exist in the same directory
strFilePath = CurrentProject.Path

' Determine the file path
If Right(strFilePath, 1) = "\" Then
strFile = strFilePath & cUDLFile
Else
strFile = strFilePath & "\" & cUDLFile
End If

If Dir(strFile, vbNormal) <> vbNullString Then
' If the udl-file exists ...
If strFile <> vbNullString Then
With cnn
On Error Resume Next
strFile = "File Name=" & strFile
.Open strFile

If Err.Number > 0 Then
MsgBox cstrMsgErrorInConnection, vbInformation,
Application.Name
DoCmd.Quit
End If

If .State = 0 Then
MsgBox "Failure - Noc connection established",
vbInformation, Application.Name
DoCmd.Quit
Else
CurrentProject.OpenConnection .ConnectionString
End If
End With
Else
MsgBox "Failure - No connection established",
vbInformation, Application.Name
DoCmd.Quit
End If
Else
MsgBox "Failure - No connection established", vbInformation,
Application.Name
DoCmd.Quit
End If

SysCmd acSysCmdClearStatus
End Function

HTH ;-)

--
Gruß, Uwe Ricken
MCP FOR MS ACCESS DEVELOPMENT
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
http://www.memberadmin.com
____________________________________________________
APP: http://www.AccessProfiPool.de
FAQ: http://www.donkarl.com/AccessFAQ.htm

Michael Gesser

unread,
Mar 6, 2003, 10:52:52 AM3/6/03
to
Hello,
Thank you for answer, maybe I should be more clear, but my problem is how to
avoid adp from connecting
to SQL Server during startup.
When I call any method of the CurrentProject object then adp tries to
connect
to server which name is currently specified and as a result I've got a delay
until this connection's failed.

Thanks.
Michael

"Uwe Ricken" <ric...@gns-online.de> wrote in message
news:#7WO6L#4CHA...@TK2MSFTNGP11.phx.gbl...

Uwe Ricken

unread,
Mar 6, 2003, 1:11:39 PM3/6/03
to
Hallo Michael,

> Thank you for answer, maybe I should be more clear, but my problem
is how to
> avoid adp from connecting

As I described ;-)

Deliver an adp with no connection.

e.g. CurrentProject.Connection = vbNullString

In this case the adp is disconnected from any server
This adp can be delivered to the customers

On startup of the adp open a form, where all possible
servers can be selected from within a list box.

Michael Gesser

unread,
Mar 10, 2003, 3:08:04 AM3/10/03
to
Thanks a lot.
Michael

"Uwe Ricken" <ric...@gns-online.de> wrote in message

news:OtWlOvA5...@TK2MSFTNGP12.phx.gbl...

0 new messages