VC怎么通过ADO获取Access中字段的标题(不是字段名)
VC如何通过ADO获取Access中字段的标题(不是字段名)?
VC如何通过ADO获取Access中字段的标题(不是字段名)?就是设计表的时候在字段中可以填的标题。
------解决方案--------------------
希望能帮到你 呵呵
------解决方案--------------------
http://blog.donews.com/zwell/archive/2004/08/06/61772.aspx
VC如何通过ADO获取Access中字段的标题(不是字段名)?就是设计表的时候在字段中可以填的标题。
------解决方案--------------------
void OpenSchemaX(TCHAR *TableName) {
HRESULT hr = S_OK;
IADORecordBinding *picRs = NULL;
_RecordsetPtr pRstSchema("ADODB.Recordset");
_ConnectionPtr pConnection("ADODB.Connection" );
pConnection->ConnectionString = TableName;
pConnection->Provider = "Microsoft.Jet.OLEDB.4.0";
try {
pConnection->Open(pConnection->ConnectionString, "", "", adModeUnknown);
pRstSchema->QueryInterface(
__uuidof(IADORecordBinding), (LPVOID*)&picRs);
pRstSchema = pConnection->OpenSchema(adSchemaTables);//枚举表的名称处理
while(!(pRstSchema->EndOfFile)) {
CString strTableType;
_bstr_t table_name = pRstSchema->Fields->GetItem("TABLE_NAME")->Value;//获取表的名称
_bstr_t table_type = pRstSchema->Fields->GetItem("TABLE_TYPE")->Value;//获取表的类型
strTableType.Format("%s",(LPCSTR) table_type);
if(!lstrcmp(strTableType,_T("TABLE"))) {
m_cbTeam.AddString((LPCSTR) table_name);//添加表的名称
}
pRstSchema->MoveNext();
}
// Clean up objects before exit.
pRstSchema->Close();
pConnection->Close();
} catch (_com_error &e) {
// Notify the user of errors if any.
// Pass a connection pointer accessed from the Connection.
PrintProviderError(pConnection);
PrintComError(e);
}
}
希望能帮到你 呵呵
------解决方案--------------------
http://blog.donews.com/zwell/archive/2004/08/06/61772.aspx