How does one connect to Oracle from VB? I need to connect to Oracle from VB and I don't know the correct way. Thank you in advance. (Excuse my english)
Call this subroutine on startup. Pass the userid, password and database server name. You could also use Microsoft's OleDB for Oracle driver. If connection is not successful, application ends. Be sure to close your connection when the application ends. (gCnn.Close)
Public Sub sExecuteLogon()
Dim Errs1 As ERRORS
Dim strtmp As String
On Error GoTo AdoError
gDBName = "Database Server Name"
'Open Connection
gConnectString$ = "UID=XXXXX" & ";PWD=XXXXX" & ";DRIVER={Microsoft ODBC for Oracle};SERVER=" & gDBName & ";"
Set gCnn = New ADODB.Connection
gCnn.Open gConnectString$
Exit Sub
AdoError:
Set Errs1 = gCnn.ERRORS
Select Case Err
Case "-2147467259"
strtmp = strtmp & vbCrLf & "Userid or Password is incorrect"
Case Else
strtmp = strtmp & vbCrLf & "Error# " & Err
End Select
MsgBox strtmp, vbExclamation, "Login Failure"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.