DAO动态打开ACESSS数据库,关于CDaoTableDefInfo的问题?

catchmeifyoucan 2003-12-01 07:15:53
在下想在DAO连接下获取数据库中的表列表,编写程序如下:
.......
CDaoTableDefInfo TableInfo;
int nTableCount=pDatabase->GetTableDefCount();
CComboBox *pComboBox=(CComboBox *)GetDlgItem(IDC_TABLENAME);
for(int i=pComboBox->GetCount()-1;i>=0;i--)
pComboBox->DeleteString(i);
for(int i=0;i<nTableCount;i++){
pDatabase->GetTableDefInfo(i,TableInfo);
pComboBox->AddString(TableInfo.m_strName);
}
..........

运行时却发现列表中多出了几个不知用途的表。我知道这应该是系统表。可我不关心他们。通过查找MSDN发现:CDaoTableDefInfo的m_lAttributes 成员变量Specifies characteristics of the table represented by the tabledef object。m_lAttributesz只能是dbAttachExclusive、dbAttachSavePWD、dbSystemObject、dbHiddenObject、dbAttachedTable 、dbAttachedODBC常量或者他们的异或。又在mfc中发现:
typedef enum TableDefAttributeEnum
{ dbAttachExclusive = 0x10000,
dbAttachSavePWD = 0x20000,
dbSystemObject = 0x80000002,
dbAttachedTable = 0x40000000,
dbAttachedODBC = 0x20000000,
dbHiddenObject = 0x1
} TableDefAttributeEnum;
那么只要判定m_lAttributes的值,就可得到表的类型。我想问的是怎样判断?
我在调试中发现自己建的表的m_lAttributes值都是是0x0,这又是为什么?
也就是说只要在pComboBox->AddString(TableInfo.m_strName)前加上if(TableInfo.m_lAttributes==0)就可得到想要的结果。问题算解决了,但是却不知为什么,请各位指教!!
...全文
56 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
比如你不想要系统表和隐藏表,就这样写
if(!(TableInfo.m_lAttributes & dbSystemObject ||
TableInfo.m_lAttributes & dbHiddenObject))
{
................
}

4,018

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧