DAO动态打开ACESSS数据库,关于CDaoTableDefInfo的问题?
在下想在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)就可得到想要的结果。问题算解决了,但是却不知为什么,请各位指教!!