怎样获得一个ACCESS表中所有的字段??谢谢 怎样获得一个ACCESS表中所有的字段??谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL CDlgRecordset::GetMicCol(){ //OnSelchangeComTable(); /*try { m_pRecordset=theApp.m_pConnection->OpenSchema(adSchemaColumns); while(!(m_pRecordset->adoEOF)) { //»ñÈ¡±í¸ñ _bstr_t col_name = m_pRecordset->Fields->GetItem("TABLE_NAME")->Value; //_bstr_t col_name = m_pRecordset->Fields->GetItem(str)->Value; //»ñÈ¡±í¸ñÀàÐÍ _bstr_t col_type = m_pRecordset->Fields->GetItem("COLUMN_TYPE")->Value; //¹ýÂËһϣ¬Ö»Êä³ö±í¸ñÃû³Æ£¬ÆäËûµÄÊ¡ÂÔ if ( strcmp(((LPCSTR)col_type),"COLUMN")==0) { m_cmbCol.AddString((LPCSTR)col_name); } m_pRecordset->MoveNext(); } m_pRecordset->Close(); }*/ _bstr_t mStrSQL; CString strSQL; CString strColName; BSTR bstrColName; long ColCount,i; Field * field = NULL; HRESULT hr; Fields * fields = NULL; LPCTSTR nameField; CString str; int nTable=m_cmbTable.GetCurSel(); m_cmbTable.GetLBText(nTable,str);// strSQL.Format("SELECT * FROM %s",str); strSQL="select * from " + str; mStrSQL=strSQL;/* if(m_pRecordset->State==1) { m_pRecordset->Close(); } m_pRecordset->Open(mStrSQL, theApp.m_pConnection.GetInterfacePtr(), adOpenKeyset, adLockOptimistic, adCmdText);*/ hr=m_pRecordset->get_Fields(&fields);//µÃµ½¼Ç¼¼¯µÄ×ֶμ¯ºÏ if(SUCCEEDED(hr)) fields->get_Count(&ColCount);//µÃµ½¼Ç¼¼¯µÄ×ֶμ¯ºÏÖеÄ×ֶεÄ×ܸöÊý for(i=0;i<ColCount;i++) { fields->Item[i]->get_Name(&bstrColName);//µÃµ½¼Ç¼¼¯ÖеÄ×Ö¶ÎÃû // UINT uType=fields->Item[i]->Type; strColName=bstrColName; nameField=strColName; m_cmbCol.AddString(nameField); }// OnSelchangeComTable(); if(SUCCEEDED(hr)) fields->Release();//ÊÍ·ÅÖ¸Õë // ¹Ø±Õ¼Ç¼¼¯/// m_pRecordset->Close(); /*catch(_com_error e)///²¶×½Òì³£ { ::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK); return FALSE; }*/ return true;} VSC#引用VC6.0开发的dll文件 MFC动态创建对话框时失败 总显示邦定错误,请看代码 在html help workshop中如何显示首页(分在HTML小类中送) 有2个比较头疼的问题请教大家 CToolBar怎么改变背景色啊 碰撞检测的问题 ADO连接 有些函数如:FUNCTION()和FUNCTIONEX()有什么联系? 有WHO知道的共享软件SinaTicker的源程序代码? 求助:如何获得浏览器地址栏中的URL (100+100)急呀--VC6工程之间可以调用吗?
{
//OnSelchangeComTable();
/*try
{
m_pRecordset=theApp.m_pConnection->OpenSchema(adSchemaColumns);
while(!(m_pRecordset->adoEOF))
{
//»ñÈ¡±í¸ñ
_bstr_t col_name = m_pRecordset->Fields->GetItem("TABLE_NAME")->Value;
//_bstr_t col_name = m_pRecordset->Fields->GetItem(str)->Value;
//»ñÈ¡±í¸ñÀàÐÍ
_bstr_t col_type = m_pRecordset->Fields->GetItem("COLUMN_TYPE")->Value;
//¹ýÂËһϣ¬Ö»Êä³ö±í¸ñÃû³Æ£¬ÆäËûµÄÊ¡ÂÔ
if ( strcmp(((LPCSTR)col_type),"COLUMN")==0)
{
m_cmbCol.AddString((LPCSTR)col_name);
}
m_pRecordset->MoveNext();
}
m_pRecordset->Close();
}*/
_bstr_t mStrSQL;
CString strSQL;
CString strColName;
BSTR bstrColName;
long ColCount,i;
Field * field = NULL;
HRESULT hr;
Fields * fields = NULL;
LPCTSTR nameField;
CString str;
int nTable=m_cmbTable.GetCurSel();
m_cmbTable.GetLBText(nTable,str);
// strSQL.Format("SELECT * FROM %s",str);
strSQL="select * from " + str;
mStrSQL=strSQL;/* if(m_pRecordset->State==1)
{
m_pRecordset->Close();
}
m_pRecordset->Open(mStrSQL,
theApp.m_pConnection.GetInterfacePtr(),
adOpenKeyset,
adLockOptimistic,
adCmdText);*/
hr=m_pRecordset->get_Fields(&fields);//µÃµ½¼Ç¼¼¯µÄ×ֶμ¯ºÏ
if(SUCCEEDED(hr))
fields->get_Count(&ColCount);//µÃµ½¼Ç¼¼¯µÄ×ֶμ¯ºÏÖеÄ×ֶεÄ×ܸöÊý
for(i=0;i<ColCount;i++)
{
fields->Item[i]->get_Name(&bstrColName);//µÃµ½¼Ç¼¼¯ÖеÄ×Ö¶ÎÃû
// UINT uType=fields->Item[i]->Type;
strColName=bstrColName;
nameField=strColName;
m_cmbCol.AddString(nameField); }
// OnSelchangeComTable();
if(SUCCEEDED(hr))
fields->Release();//ÊÍ·ÅÖ¸Õë
// ¹Ø±Õ¼Ç¼¼¯
/// m_pRecordset->Close();
/*catch(_com_error e)///²¶×½Òì³£
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
return FALSE;
}*/
return true;}