Written using an ADO + DataGridProgram, Compilation is normal. "rowset" appears during running
Is not bookmarkable ", check the function call and type. No problem.
Search. It turns out to be a cursor problem.
Add m_precordset-> cursorlocation = aduseclient to the getrecordset method of the adoconn class;
that is:
// execute the query
_ recordsetptr & adoconn: getrecordset (_ bstr_t bstrsql)
{< br> try
{< br> // connect to the database. If the connection object is null, reconnect to the database.
If (m_pconnection = NULL)
oninitadoconn ();
// create a record set object
m_precordset.createinstance (_ uuidof (recordset);
// Add this sentence.
m_precordset-> cursorlocation = aduseclient; // The cursor position appears. if you do not add this statement, the rowset is not // bookmarkable running error may occur.
// Obtain records in the table
M_precordset-> open (bstrsql, m_pconnection.getinterfaceptr (), adopendynamic, adlockoptimistic, adshorttext );
}
// Catch exceptions
Catch (_ com_error E)
{
// Display the error message
Afxmessagebox (E. Description ());
}
// Return record set
Return m_precordset;
}
The call method is as follows:
Bool cdatagriddlg: oninitdialog ()
{
Cdialog: oninitdialog ();
// OriginalCodeOmitted
// Todo: add extra initialization here
//************************************** **********************
Adoconn m_ado;
_ Bstr_t vsql = "select * from users ";
_ Recordsetptr m_precordset;
M_ado.oninitadoconn ();
M_precordset = m_ado.getrecordset (vsql );
M_datagrid.setrefdatasource (lpunknown) m_precordset); // m_datagrid is the variable of the DataGrid Control.
//************************************** **********************
Return true; // return true unless you set the focus to a control
}