VB6.0 Connect to the ADO object:

zhaozj2021-02-17  36

1. Define connection objects

Global dbconnect as new adodb.connection

2. Perform connection statement

If dbconnect.state = adStateOpen and not ity (adstateopen) THEN DBCONNECT.CLOSE

l Connect ODBC

Dbconnect.connectionstring = "DSN = DataAliasName; UID = UserId; PWD = passwd;"

l Connect directly to Access

Dbconnect.Provider = "Microsoft.jet.OleDb.4.0" // Access 97 is 3.51

Dbconnect.connectionstring = "filepath / filename.mdb"

l Connect Oracle

Dbconnect.Provider = "msadora"

Dbconnect.connectionstring = "User / mypass @ service

l Connect to SQL Server

Dbconnect.Provider = "SQLOLEDB.1"

Dbconnect.connectionstring = "Database =; server =; uid =; pwd =;"

Or you can use dbconnect.open "Server", "UserID", "Password"

Dbconnect.open

3. Take the query result set

Global RS As New AdoDb.Recordset

Global ps as new adodb.recordset

IF rstate = adStateOpen and not ingsempty (adstateopen) Then Rs.close

Rs.open sqlstr, dbconnect, adopenkeyset

4. Execute SQL statement

Dbconn.execute SQLSTR

5. Close the database

Dbconnect.close

转载请注明原文地址:https://www.9cbs.com/read-30621.html

New Post(0)