Question:
I’m trying to connect to DB2 tables from an Access db using VB. What Am I Missing?
2008-05-19 10:17:31 UTC
I’m linked to the DB2 tables, which are password protected, and I make a connection using the following code but still get the data source logon screen if I run a query against the DB2 table:

' Open Connection to the Database
Public Function OpenDBConnection() As Variant
On Error GoTo Error_Label

Dim strUserID As String ' User ID
Dim strPassword As String ' Password

strUserID = myid
strPassword = mypasw

' Get Database Connection
Set dbConnection = New ADODB.Connection
dbConnection.Open "DSN=DB214;UID=" + strUserID + ";PWD=" + strPassword

' Check if Connection is OPEN or CLOSED
If dbConnection.State = adStateClosed Then
MsgBox "Database Connection Closed", vbCritical, "DB Connection Error"
End If

Exit Function

Error_Label:
MsgBox "Cannot Connect To Database. Database Connection Failed", vbCritical, "DB Connection Error"

End Function
Three answers:
SoulCollector
2008-05-19 10:24:20 UTC
check your code again there is a syntax error in the sentance you have used to open the connection.
JB
2008-05-19 10:29:19 UTC
My data source provider gives me the option of "Always Prompt For Login Information".



I would double check your data source to make sure it doesn't have something similar.
Got Security?
2008-05-19 10:25:42 UTC
maybe specify provider in your connection string?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...