Home > Archive > MS SQL Server Connectivity > April 2006 > How to connection MS Access Porject (.adp) with SQL server?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to connection MS Access Porject (.adp) with SQL server?
Pat

2006-04-06, 11:24 am

Hi all,

I got the question, how can i connection MS Access Project to a SQL Server
in vba in runtime.

The situation is i create a new MS Access Project, it's didn't have any
connection with any SQL-server. It's just consist a couple of form. What i
want is that user can via an inlog form to get in the database. The
informations about the server...etc is save in the code. The user just need
to give the SQL-login and password. My code to make the connection is as
follow.

'-------------------------------------------------------------------------------------------

Function GetADPConnection(str
Servername, strDBName As String, Optional strUN
As String, _ Optional strPW As String)

Dim strConnect as string

strConnect = "Provider=SQLOLEDB" & _
";Data Source = \10.0.0.4\" & strServername & _
";Initial Catalog =" & strDBName
strConnect = strConnect & ";UID=" & strUN
strConnect = strConnect & ";PWD=" & strPW
Application.CurrentProject.OpenConnection strConnect

End Function

'-----------------------------------------------------------------------------------------

It doesn't seems to work and i get the following error messagge:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access
denied.

Can anyone help?

Best Regards,

Pat


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com