ADO gets the code of the field name

xiaoxiao2021-03-06  41

HRESULT HR;

_BSTR_T MSTRSQL;

CString strcolname;

BSTR BSTRCOLNAME;

Long colcount, i;

Fields * Fields = NULL;

/ / Open the record set, get the field name, and add field name information to listbox

MSTRSQL = "SELECT * from Image";

m_precordset-> Open (MSTRSQL,

m_pconnection.getInterfacePtr (),

AdoPENDYNAMIC,

AdlockOptimistrc,

AdcmdText);

HR = m_precordset-> get_fields (& fields);

/ / Get the field set of records and

En (ac))

Fields-> Get_count (& colcount);

M_Listbox.resetContent ();

/ / Get the total number of fields in the field collection of records

For (i = 0; i

{

Fields-> item [i] -> get_name (& bstrcolname); // get the field name in the recordset

Strcolname = BSTRCOLNAME;

Namefield = strcolname;

m_listbox.addstring (namefield);

}

En (ac))

m_precordset-> close ();

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

New Post(0)