_ Variant_t vusername, vbirthday, vid, vold;
_ Recordsetptr m_precordset;
M_precordset.createinstance ("ADODB. recordset ");
M_precordset-> open ("select * from users", _ variant_t (idispatch *) m_pconnection, true), adopenstatic, adlockoptimistic, adshorttext );
While (! M_precordset-> adoeof) // Why is it adoeof instead of EOF? Do you still remember Rename ("EOF", "adoeof?
{
// My previousProgramThe force type conversion results always report exceptions, so they are resentful.
 
 
Vid = m_precordset-> getcollect (_ Variant_t (long) 0 )) ; /// Get the value of the 1st column and start counting from 0. You can also give the column name directly, as shown in the following line
Vusername = m_precordset-> getcollect ("username"); // obtain the value of the username field
Vold = m_precordset-> getcollect ("old ");
Vbirthday = m_precordset-> getcollect ("Birthday ");
/// Records in the output window output record set in debug mode
If (VID. VT! = Vt_null & vusername. VT! = Vt_null & vold. VT! = Vt_null & vbirthday. VT! = Vt_null)
Trace ("ID: % d, name: % s, age: % d, birthday: % S/R/N", vid. lval, (lpctstr) (_ bstr_t) vusername, vold. lval, (lpctstr) (_ bstr_t) vbirthday );
M_precordset-> movenext (); // move to the next record
}
M_precordset-> movefirst (); // move to the first record
M_precordset-> Delete (adaffectcurrent); // Delete the current record
/// Add three new records and assign values
For (INT I = 0; I <3; I ++)
{
M_precordset-> addnew (); // Add a new record
M_precordset-> putcollect ("ID", _ variant_t (long) (I + 10 )));
M_precordset-> putcollect ("username", _ variant_t ("Silverlight "));
M_precordset-> putcollect ("old", _ variant_t (long) 71 ));
M_precordset-> putcollect ("Birthday", _ variant_t ("1930-3-15 "));
}
M_precordset-> move (1, _ variant_t (long) adbookmarkfirst); // move a record from the first record to the second record.
M_precordset-> putcollect (_ variant_t ("old"), _ variant_t (long) 45); // modify the age
M_precordset-> Update (); // save it to the database.