Link to home
Start Free TrialLog in
Avatar of cipriano555
cipriano555

asked on

VBA with ADO: How can you set the Provider property of a connection in Access 2013

I am trying to set the value of the connection string property.  My data is not in Access, it is in SQL Server, I'm just using Access to develop a front end.

I have been following a text book, but when I follow their example, it does not work.  I created a button, and an afterclick event handler for it.   See below, it is the assignment statement for sConn that doesn't work.

Private Sub Command3_Click()
Dim adConn As ADODB.Connection
Dim sConn As String
Set adCon = New ADODB.Connection


sConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False; Initial Catalog=DATA_CONCEPTS;Data Source=SRVR7LF\MSSQL2012"

adConn.ConnectionString = sConn
adConn.Open

MsgBox (adConn.Provider)

adConn.Close
Set adConn = Nothing
End Sub
ADO-ERROR-1.JPG
ADO-ERROR-2.JPG
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cipriano555
cipriano555

ASKER

Yikes, amazingly dense on my part.  Thanks, that fixed it.