Author: bluesky35 (blue) must first install the ORACLE client or server-side, and built DB SERVICE, after a successful connection can begin, the following is access ORACLE VB code: Option Explicit 'Here are some variables and define parameters' the DB name Public Const strdbname = "DBNAME" 'user name Public Const strusr = "BLUESKY35"' password Public Const strpwd = "pASSWORD" function 'OraSessionPublic OraSession As Object'OraDatabasePublic oraDB As OraDatabase'OraDynasetPublic OraDyn As OraDynaset' connected to the ORACLE ' the connection is successful: true connection failed: falsePublic Function f_connect () As Boolean On Error GoTo ierr f_connect = False Set OraSession = CreateObject ( "OracleInProcServer.XOraSession") Set oraDB = OraSession.OpenDatabase (strdbname, strusr & "/" & strpwd, 0 & ) f_connect = True Exit Function ierr: MsgBox Err.Description, vbOKOnly vbCritical, "Error" f_connect = FalseEnd Function 'access to records Public Function f_select (strsql As String) from a database table by passing SQL statements As OraDynaset
On Error GoTo ierr Set OraDyn = OraDB.CreateDynaset (strsql, ORADYN_READONLY) Set f_select = OraDyn Exit Function ierr: MsgBox Err.Description, vbOKOnly vbCritical, "Error" Set f_select = NothingEnd Function 'to perform the update statement that returns affected by this update Number of influences PUBLIC FUNCTION F_EXECUTE (STRSQL AS STRING) AS Boolean
On Error GoTo ierr f_execute = False OraDB.BeginTrans f_execute = OraDB.ExecuteSQL (strsql) Exit Function ierr: MsgBox Err.Description, vbOKOnly vbCritical, "Error" OraDB.RollbackEnd Function 'Disconnect' off Success: true OFF Failure: falsepublic function f_disconnect () AS Boolean