_ Connectionptr is a connection interface. First, create a _ connectionptr interface instance, and then point to and open an ODBC data source or ole db data provider (provider ). BelowCodeCreate a data connection based on DSN and non-DSN respectively.
// Use _ connectionptr (based on DSN)
_ Connectionptr mydb;
Mydb. createinstance (_ uuidof (connection ));
Mydb-> open ("DSN = Samp; uid = admin; Pwd = admin", "", ",-1 );
// Use-connectionptr (based on non-DSN)
_ Connectionptr mydb;
Mydb. createinstance (_ uuidof (connection ));
Mydb. Open ("provider = sqloledb; server = server; database = Samp; uid = admin; Pwd = admin", "", "",-1 );
// Use _ recordsetptr to execute an SQL statement
_ Recordsetptr myset;
Myset. createinstance (_ uuidof (recordset ));
Myset-> open ("select * from some _ table", mydb. getinterfaceptr (), adopendynamic, adlockoptimistic, adshorttext );