请教大家,如何设定Crysatal Report的数据源为ADO数据源?使用Crystal Report做报表必须用rpt模版文件吗?我用的VC6.0

telfish 2007-04-05 01:58:26
请大家帮忙回答,非常感谢,我的分少,全部相送!
...全文
226 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
telfish 2007-04-10
  • 打赏
  • 举报
回复
非常感谢xscansou()回答,但是我还是没弄明白是否一定需要.rpt文件。我分两种情况试了一下:
1:不要.rpt文件,做完ADO查询后直接用
m_Report->Database->SetDataSource(_variant_t((IDispatch*)pRst,true),(long)3,long(1));
m_crview1.SetReportSource(m_Report);

m_crview1.Refresh ();

m_crv1iew.ViewReport();

编译运行,提示:
Runtime error!
Progra: D:\...(我程序的目录)\.exe
abnormal program termination

2:用.rpt文件
//实例化m_Application
m_Application.CreateInstance (__uuidof(Application));

CString strTemplatePath;
char strAppPath[150];
CString theApppath;

GetCurrentDirectory(150,strAppPath);
theApppath=strAppPath;

strTemplatePath=theApppath+"\\report\\Report20070406.rpt";


_bstr_t ReportPath(strTemplatePath);


m_Report =m_Application->OpenReport(ReportPath);

m_Report->Database->SetDataSource(_variant_t((IDispatch*)pRst,true),(long)3,long(1));

m_crview1.SetReportSource(m_Report);

m_crview1.Refresh ();

m_crv1iew.ViewReport();

编译运行都没有错,但是报表中没有数据。

麻烦您帮我分析一下好吗?

另外,怎么给你分呀,如何操作?
谢谢了


xscansou 2007-04-06
  • 打赏
  • 举报
回复
//设置报表数据源
m_Report->Database->SetDataSource(_variant_t((IDispatch*)m_pRs,true),(long)3,long(1));

4,011

社区成员

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

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