Implementation principle: Oracle database connection is implemented using Microsoft ODBC for Oracle.
Connect to the ACCESS database using the Oracle database string and the "ADODB. Connection" object. Determine whether the database can be connected successfully.
Note: The current computer must contain ADODB. Connection objects.
Source code:
Export prototype bool db_check1_lercon (byref string, byref string );
// Driver = {Microsoft ODBC for Oracle}; server = myserveraddress; uid = myusername; Pwd = mypassword;
// Driver = {Microsoft ODBC driver for Oracle}; connectstring = oracleserver. World; uid = myusername; Pwd = mypassword;
// ================================================ ======================================== //
// Function: db_checkpoliclercon //
////
// Purpose: test whether oracl can be connected //
////
// Argment: svservername-name of the Oracle Connection Service //
// Svusername-Logon account //
// Svuserpassword-Logon password //
// Return: True-connection succeeded; false-Connection Failed //
// Remark: This verification uses Microsoft ODBC for Oracle verification //
// ================================================ ======================================== //
Function bool db_checkpoliclercon (svservername, svusername, svuserpassword, szerror)
Object padoconnobj, padorecordsetobj, pdbconobj;
String szadoconnobjid, szadorecordsetobjid, szconnstring, szsql, svdriver;
Bool bexists;
Begin
Svdriver = "Microsoft ODBC for Oracle ";
Bexists = false;
Try
// Create ADO connection object to connect to the SQL Server
Szadoconnobjid = "ADODB. Connection ";
Set padoconnobj = Createobject (szadoconnobjid );
// Create the Oracle string to complete the connection
Szconnstring = "driver = {" + svdriver + "};";
Szconnstring = szconnstring + "Server =" + svservername + ";";
Szconnstring = szconnstring + "uid =" + svusername + ";";
Szconnstring = szconnstring + "Pwd =" + svuserpassword + ";";
// Szconnstring = szconnstring + "database = Master ";
// Open the ADO connection
Padoconnobj. Open (szconnstring );
Bexists = true;
Catch
Sprintf (szerror, "error: Number: % d;", Err. number );
Szerror = szerror + "Desc:" + err. description;
Bexists = false;
// Clean up
Set padoconnobj = nothing;
Endcatch;
Set padoconnobj = nothing;
Return bexists;
End;