获取数据库的表名并交其放入combobox的下拉列表中。程序无错,就是无法实现该功能,求大神指点。
BOOL CAboutDlg::GetTableName()BOOL CAboutDlg::GetTableName();{
try {
_RecordsetPtr m_pRecordset=m_pConnection->OpenSchema(adSchemaTables);
while(!(m_pRecordset->adoEOF)) {
// 获取表的名称
_bstr_t table_name = m_pRecordset->Fields->GetItem("TABLE_NAME")->Value;
// 获取表的类型
_bstr_t table_type = m_pRecordset->Fields->GetItem("TABLE_TYPE")->Value;
// 添加表的名称
CComboBox combobox;
combobox.AddString((LPCSTR)table_name);//m_cmbTable是表名显示的地方
m_pRecordset->MoveNext();
}
m_pRecordset->Close();
} catch(_com_error e) {
// Notify the user of errors if any.
// Pass a connection pointer accessed from the Connection.
::MessageBox(NULL,e.Description(),"出错了!",MB_OK);
return FALSE;
}
}