大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 媒体动画 -> 3DSMax -> 获取ACCESS2000数据库中所有表的名称

获取ACCESS2000数据库中所有表的名称

时间: 2021-07-31 作者:daque

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);

}

挪用本领:

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);

}(根源:风闪网路学院)

 

<

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.