1. Define the connection object
Global dbconnect as new ADODB. Connection
2. Execute the connection statement
If dbconnect. State = adstateopen and not isempty (adstateopen) Then dbconnect. Close
Connect to ODBC
Dbconnect. connectionstring = "DSN = dataaliasname; uid = userid; Pwd = passwd ;"
Directly connect to access
Dbconnect. provider = "Microsoft. Jet. oledb.4.0" // Access 97 IS 3.51
Dbconnect. connectionstring = "filepathfilename. mdb"
Connect to Oracle
Dbconnect. provider = "msadora"
Dbconnect. connectionstring = "User/mypass @ servicename
Connect to SQL Server
Dbconnect. provider = "sqloledb.1"
Dbconnect. connectionstring = "database =; server =; uid =; Pwd = ;"
Alternatively, you can use dbconnect. Open "server", "userid", "password"
Dbconnect. Open
3. Retrieve the query result set
Global RS as new ADODB. recordset
Global PS as new ADODB. recordset
If Rs. State = adstateopen and not isempty (adstateopen) Then Rs. Close
Rs. Open sqlstr, dbconnect, adopenkeyset
4. Execute SQL statements
Dbconn. Execute sqlstr
5. Shut down the database
Dbconnect. Close