1 打开连接:pConnection->Open((_bstr_t)strConnStr, "", "", adModeUnknown);
2 取得所打开文件中所有的表名:
pTableNameRecordset = pConnection->OpenSchema(adSchemaTables);
while(!pTableNameRecordset->adoEOF)
{
_bstr_t table_name = pTableNameRecordset->Fields->GetItem("TABLE_NAME")->Value; //Get table name inside access file
_bstr_t table_type = pTableNameRecordset->Fields->GetItem("TABLE_TYPE")->Value; //Get table type of corresponding table
//if ((LPCTSTR)table_type == L"TABLE")
if(strcmp(table_type, "TABLE") == 0) //judge the type of table

本文介绍了如何在MFC应用中使用ADO组件来连接并读取Access数据库的步骤,包括打开数据库连接、获取表名、选择特定表、读取字段名及对应的行数据。
最低0.47元/天 解锁文章
3293

被折叠的 条评论
为什么被折叠?



