📄 subject_37099.htm
字号:
<p>
序号:37099 发表者:xuan 发表日期:2003-04-21 21:47:02
<br>主题:要用_RecordsetPtr需要加入哪些头文件???
<br>内容:要在一个数据库工程中用_RecordsetPtr和_ConnectionPtr这两咱类型,要在头文件中加入那些头文件啊,谁能帮忙,小弟在此多谢先
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:擎天柱 回复日期:2003-04-21 21:50:58
<br>内容:#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \<BR>no_namespace rename("EOF", "EndOfFile")<BR><BR>#include <stdio.h><BR><BR>void main(void)<BR>{<BR> CoInitialize(NULL);<BR> try <BR> {<BR> _ConnectionPtr pConn("ADODB.Connection");<BR> _RecordsetPtr pRst("ADODB.Recordset");<BR><BR> pConn->Open("Provider=sqloledb;Data Source=MyServer;"<BR> "Initial Catalog=pubs;User Id=sa;Password=;", <BR> "", "", adConnectUnspecified);<BR>// Note 1.<BR> pRst->Open(<BR> "authors",<BR> _variant_t((IDispatch *) pConn, true),<BR> adOpenStatic,<BR> adLockReadOnly,<BR> adCmdTable);<BR> pRst->MoveLast();<BR>// Note 2.<BR> printf("Last name is '%s %s'\n", <BR> (char*) ((_bstr_t) pRst->GetFields()->GetItem("au_fname")->GetValue()),<BR> (char*) ((_bstr_t) pRst->Fields->Item["au_lname"]->Value));<BR><BR> pRst->Close();<BR> pConn->Close();<BR> }<BR> catch (_com_error &e)<BR> {<BR> printf("Description = '%s'\n", (char*) e.Description());<BR> } <BR>::CoUninitialize();<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -