ODBC через DAO

CDaoDatabase MyDb = new CDaoDatabase();

m_DaoServerDB.Open(NULL,FALSE,FALSE,
"ODBC;DSN=SAMS_SVR;UID=admin;PWD=admin");

CDaoRecordset MySet = new CDaoRecordset(MyDb);
MySet->Open(AFX_DAO_USE_DEFAULT_TYPE,
"SELECT * FROM some_table");

VARIANT *vFieldValue;
COleVariant covFieldValue;
CString Holder;

while(!MySet->IsEOF())
{
MySet->GetFieldValue("FIELD_1", covFieldValue);
vFieldValue = (LPVARIANT)covFieldValue;

if(vFieldValue->vt!-VT_NULL)
{
Holder.Format("%s",vFieldValue->pbVal);
m_List.AddString(Holder);
}

MySet.MoveNext();
}

 

 
« Предыдущая статья