Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does one connect to Oracle from VB with ODBC?

Status
Not open for further replies.

mamen

Programmer
Jan 11, 2006
2
0
0
ES
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"

'Perform Shutdown
End
End Sub
 
Thank you for the reply. I'll try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top