首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

ado连接sql2005的读取有关问题

2012-02-08 
ado连接sql2005的读取问题开发环境是vc6.0加sql2005代码:CoInitialize(NULL)_ConnectionPtr pConn(__uuid

ado连接sql2005的读取问题
开发环境是vc6.0加sql2005
代码:
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
pConn->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=bingle;Data Source=(local)";
pConn->Open("","","",adConnectUnspecified);
pRst = pConn->Execute("select * from myTable1",NULL,adCmdText);
while(!pRst->EndOfFile)
{
wchar_t* str=(wchar_t *)(_bstr_t)pRst->GetCollect("bingle2");

printf("%s\n",str);
pRst->MoveNext();
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
红色标注的地方不知道怎么转化。bingle2是一个varchar(50)的column,数据是test1,haha1
但是读出的结果确实数据的首字母,也就是t和h。我不知道为什么会这样,纠结老长时间了,望坛友多帮忙!

[解决办法]

探讨
建议去VC版问问

[解决办法]
是不是指针取址的问题,去问问相关人士

热点排行