I’m trying to open a connection with the following function:
Public cn1 As New ADODB.Connection
'Sub to open connection to database
Public Function OpenConnection(ByVal strOpenConnectionString As String, _
Optional ByVal lngOpenConnectionTimeout As Long = 3600) As Long
With cn1
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.Mode = ADODB.ConnectModeEnum.adModeUnknown
.ConnectionTimeout = lngOpenConnectionTimeout
.CommandTimeout = lngOpenConnectionTimeout
.ConnectionString = strOpenConnectionString
End With
Try
cn1.Open()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
OpenConnection = cn1.State
End Function
I’m using windows authentication for my connection and my connection string is:
"Integrated Security=SSPI;Initial Catalog=Test;Data Source=PEDRAM-PC\PEDRAM"
I can connect easily when I use an sql connection but I need to do it with that ado db object because it’s my company code.
I get the following exception:

Can anyone tell me what I’m doing wrong?
You will need to use a different connection string for ADODB. Try This