Practical Web Programming

Monday, October 22, 2007

How to Connect to an Oracle Database in Visual Basic

This is ready to use function written in Visual Basic 6. This function will connect to an oracle database. See the sourcecodes below.

'Procedure: ConnectOracle
'Language: Visual Basic 6
'Parameter: strUN = username,
' strPW = password,
' strHost = host string
'Purpose: This procedure will connect to a Oracle database
'Usage: Call ConnectOracle("scott", "tiger", "oradb")

Public Sub ConnectOracle(strUN As String, _
strPW As String, _
strHost As String)
Dim Conn = New ADODB.Connection
Conn.Open "Provider=OraOLEDB.Oracle.1;" & _
"Persist Security Info=False;" & _
"User ID='" & strUN & "';" & _
"Data Source='" & strHost & "';" & _
"Password= '" & strPW & "'"
End Sub

0 comments:

Recent Post