The rowset is not bookmarkable "error

Source: Internet
Author: User

 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
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.