菜鸟级问题,请教大虾们:) http://codeguru.earthweb.com/mfc_database/unbound_dbgrid.shtmlUsing DBGrid in unbound mode 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // set datasource of DBGrid dynamically void CDgDlg::OnOK() { //notes : call AfxOleInit in CXXApp::InitInstance() // I also add a line in stdafx.h //#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile") try { _ConnectionPtr pConn("ADODB.Connection"); _RecordsetPtr pRst("ADODB.Recordset"); pConn->Open("Provider=sqloledb;Data Source=Dell1;" "Initial Catalog=testdb;User Id=sa;Password=;", "", "", adConnectUnspecified); pRst->Open( "table1", _variant_t((IDispatch *) pConn, true), adOpenStatic, adLockReadOnly, adCmdTable); //CDataGrid m_grid; is a member of CDgDlg. m_grid.SetRefDataSource(pRst.Detach()); } catch (_com_error &e) { char mybuf[10240]; wsprintf(mybuf,"Description = '%s'\n", (char*) e.Description()); AfxMessageBox(mybuf); }} To masterz:刚试过,编译的时候出错,说类型不匹配 Recordset * 不能转换成 DataSource *,怎么办? 我觉得DBGRID不好用,还是CListView好用! 执行dll中的代码却进到别的函数中,求高手指点 为什么D3D中CreateDevice之后浮点数计算出现很大误差 高手帮我分析分析这段代码怎么回事? 求指点,求帮助! 简单的基于VFW视频压缩问题 Directx建立地形的相关问题 ****又一个简单的问题***** 请教大侠,我想在程序里判断某个程序是否在运行,请问如何实现谢谢! 使用CFile类遇到的小问题,多多指点!! 我要怎么样才能用ASC CHR$等C函数?include哪个文件?我还在学DOS下面的C 用VC编写收发电子邮件应该注意的问题,谁能提醒一下? 怎样将clistctrl树视图中的一项设为隐藏?
void CDgDlg::OnOK()
{ //notes : call AfxOleInit in CXXApp::InitInstance()
// I also add a line in stdafx.h
//#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
try
{
_ConnectionPtr pConn("ADODB.Connection");
_RecordsetPtr pRst("ADODB.Recordset");
pConn->Open("Provider=sqloledb;Data Source=Dell1;"
"Initial Catalog=testdb;User Id=sa;Password=;",
"", "", adConnectUnspecified);
pRst->Open(
"table1",
_variant_t((IDispatch *) pConn, true),
adOpenStatic,
adLockReadOnly,
adCmdTable);
//CDataGrid m_grid; is a member of CDgDlg.
m_grid.SetRefDataSource(pRst.Detach());
}
catch (_com_error &e)
{
char mybuf[10240];
wsprintf(mybuf,"Description = '%s'\n", (char*) e.Description());
AfxMessageBox(mybuf);
}
}
刚试过,编译的时候出错,说类型不匹配 Recordset * 不能转换成 DataSource *,
怎么办?