关于_ConnectionPtr的用法

suxk 2003-05-18 02:25:39
_ConnectionPtr都有什么用法?可不可以得到,用它打开的数据库中的表名?要知道那个表里面有哪些字段怎么办?
...全文
330 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
drip 2003-05-19
  • 打赏
  • 举报
回复
要用_ConnectionPtr的条件是什么?如要有什么头文件。加入什么lib文件等。(我是初学者(脸都红了))
suxk 2003-05-19
  • 打赏
  • 举报
回复
用_RecordSetPtr大开不是需要添加表的参数吗?还有用那些函数可以得到
suxk 2003-05-19
  • 打赏
  • 举报
回复
能不能说的详细点
jerkzzz 2003-05-19
  • 打赏
  • 举报
回复
见msdn例子的前半段
// BeginItemCpp
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")

#include <ole2.h>
#include <stdio.h>
#include <conio.h>

// Function declarations
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ItemX(void);
void PrintProviderError(_ConnectionPtr pConnection);
void PrintComError(_com_error &e);

//////////////////////////////////////////////////////////
// //
// Main Function //
// //
//////////////////////////////////////////////////////////

void main()
{
if(FAILED(::CoInitialize(NULL)))
return;

ItemX();

//Wait here for the user to see the output
printf("Press any key to continue...");
getch();
::CoUninitialize();
}

//////////////////////////////////////////////////////////
// //
// ItemX Function //
// //
//////////////////////////////////////////////////////////

void ItemX(void)
{
HRESULT hr = S_OK;

// Define ADO object pointers.
// Initialize pointers on define.
// These are in the ADODB:: namespace.
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRst = NULL;
_CommandPtr pCmd = NULL;
_ParameterPtr pPrm = NULL;
FieldPtr pFld = NULL;

// Other Variables.
_bstr_t strCnn("Provider=sqloledb;Data Source=10.93.121.36;"
"Initial Catalog=pubs;User Id=sa;Password=1111;");
_variant_t Column[9];
_variant_t vIndex;

try
{
// Open connection.
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));

TESTHR(pRst.CreateInstance(__uuidof(Recordset)));

TESTHR(pCmd.CreateInstance(__uuidof(Command)));

Pollux2008 2003-05-18
  • 打赏
  • 举报
回复
那得用_RecordSetPtr

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧