标题:求助:用ADO连接数据库如何把库中的数据显示在对话框的控件中
取消只看楼主
sula0613
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-3-29
 问题点数:0 回复次数:0 
求助:用ADO连接数据库如何把库中的数据显示在对话框的控件中

CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));

pConn->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=py;Initial Catalog=StudentDB";
pConn->Open("","","",-1);

pRst=pConn->Execute("select * from student",NULL,adCmdText);
// while(!pRst->rsEOF)
//{
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(
(_bstr_t)pRst->GetCollect("StudentNo"));
m_StudentNo==(_bstr_t)pRst->GetCollect("StudentNo");
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();

CoUninitialize();
m_StudentNo为控件的数据成员 ,为什么在对话框中列表控件能显示,而编辑控件不能显示数据?

搜索更多相关主题的帖子: 数据库 对话框 ADO 控件 
2006-03-29 15:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-53689-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.103827 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved