国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

獲取ACCESS2000數(shù)據(jù)庫(kù)中所有表的名稱

2024-07-21 02:13:37
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

void openschemax(tchar *tablename)
{
hresult hr = s_ok;

::coinitialize(null); //初始化com

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_strlist.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);
}
couninitialize();
}

void printprovidererror(_connectionptr pconnection)
{
errorptr perr = null;

if( (pconnection->errors->count) > 0)
{
long ncount = pconnection->errors->count;
// collection ranges from 0 to ncount -1.
for(long i = 0;i < ncount;i++)
{
perr = pconnection->errors->getitem(i);
cstring strerror;
strerror.format("error number: %x/t%s", perr->number, perr->description);
afxmessagebox(strerror);
}
}
}

void printcomerror(_com_error &e)
{
_bstr_t bstrsource(e.source());
_bstr_t bstrdescription(e.description());

// print com errors.
cstring strerror;
strerror.format("error number: description = %s/tcode meaning = %s",(lpcstr) bstrdescription, e.errormessage());
afxmessagebox(strerror);
}

調(diào)用方法:

cstring strfilename;
tchar filename[max_path];
tchar bigbuff[2048] = _t(""); // maximum common dialog buffer size
tchar szfilter[] = _t("text files (*.mdb)|*.mdb|all files (*.*)|*.*
");
cfiledialog dlg(true, null, null,
ofn_hidereadonly | ofn_allowmultiselect, szfilter);

// modify openfilename members directly to point to bigbuff
dlg.m_ofn.lpstrfile = bigbuff;
dlg.m_ofn.nmaxfile = sizeof(bigbuff);

if(idok == dlg.domodal() )
{
strfilename = dlg.getpathname();
lstrcpy(filename,strfilename);
openschemax(filename);
}(出處:風(fēng)閃網(wǎng)路學(xué)院)

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 堆龙德庆县| 安岳县| 迁西县| 临武县| 秦皇岛市| 克什克腾旗| 五华县| 雅安市| 祁阳县| 红河县| 宜兴市| 罗源县| 永丰县| 古丈县| 香格里拉县| 辰溪县| 富锦市| 济源市| 兴海县| 清徐县| 江安县| 玉环县| 墨脱县| 苏尼特左旗| 沅陵县| 筠连县| 焦作市| 江北区| 札达县| 秀山| 永安市| 新绛县| 湛江市| 五常市| 兴安县| 二连浩特市| 长顺县| 囊谦县| 庆安县| 许昌县| 白朗县|