我是参考一文章《水晶报表在VC++6.0中的简单使用方法》写的。
其中:
//水晶报表变量
IApplicationPtr m_Application;
IReportPtr m_Report;
//水晶报表控件变量,在对话框中加入该控件
CCrystalReportViewer9 m_CRViewer1;原代码如下:
m_Application.CreateInstance(__uuidof(Application));
m_Report = m_Application->OpenReport("1.rpt");
m_Report->put_ReportTitle (_bstr_t("Title"));
m_Report->Database->Tables->Item[1]->SetLogOnInfo("10.100.128.21","fmb","sa","111");
BSTR m_str = (m_pView->m_sql).AllocSysString();//m_pView->m_sql为一CString类型的SQL查询语句
HRESULT hr = m_Report->put_SQLQueryString(m_str);
if (FAILED(hr))
{
MessageBox("error");//总是显示这个
} m_CRViewer1.SetReportSource(m_Report);
m_CRViewer1.SetDisplayToolbar(TRUE);
m_CRViewer1.SetDisplayGroupTree(FALSE);
m_CRViewer1.SetDisplayBorder(FALSE);
m_CRViewer1.Refresh();
m_CRViewer1.ViewReport();执行到m_Report->put_SQLQueryString(m_str);后,总是显示error。
当然结果也是设计报表时的结果,而非动态查询后的结果。请高手指正,如何解决?
其中:
//水晶报表变量
IApplicationPtr m_Application;
IReportPtr m_Report;
//水晶报表控件变量,在对话框中加入该控件
CCrystalReportViewer9 m_CRViewer1;原代码如下:
m_Application.CreateInstance(__uuidof(Application));
m_Report = m_Application->OpenReport("1.rpt");
m_Report->put_ReportTitle (_bstr_t("Title"));
m_Report->Database->Tables->Item[1]->SetLogOnInfo("10.100.128.21","fmb","sa","111");
BSTR m_str = (m_pView->m_sql).AllocSysString();//m_pView->m_sql为一CString类型的SQL查询语句
HRESULT hr = m_Report->put_SQLQueryString(m_str);
if (FAILED(hr))
{
MessageBox("error");//总是显示这个
} m_CRViewer1.SetReportSource(m_Report);
m_CRViewer1.SetDisplayToolbar(TRUE);
m_CRViewer1.SetDisplayGroupTree(FALSE);
m_CRViewer1.SetDisplayBorder(FALSE);
m_CRViewer1.Refresh();
m_CRViewer1.ViewReport();执行到m_Report->put_SQLQueryString(m_str);后,总是显示error。
当然结果也是设计报表时的结果,而非动态查询后的结果。请高手指正,如何解决?
解决方案 »
- 求救:困扰了几天的问题!!!!!!!!!!!!!!
- 加密算法
- 如何用vc实现对游戏手柄的操作?
- 一个礼拜没搞定只好想这么一个办法求源代码:mfc主程序起来后要求用creatprocess调notepad程序,然后锁住系统的键盘和鼠标,其间可以按下
- 有什么API函数能检测到麦克风的音量的?
- 求助(关于函数。。。
- 十万火急!小女子做数字图像处理,请各位大哥提示:如何找到将JPEG(JPG)文件格式转化成BMP文件格式的C源码?
- 怎样在单文档程序中处理最大化消息
- 这段代码有什么问题吗?
- vc++6.0运行出错问题
- 帮忙看段代码,怎么窗口会不停闪动呢,关于ListView 控件使用的,帮帮忙
- 基类是CEditView,如何修改在视图中鼠标右键单击弹出的菜单
你要写一个过滤器,是这样的。
你去下载一些例子看看吧。
没有必要去写一个SQL语句的。m_Report->RecordSelectionFormula="{StudentList.成绩}>60";
m_wndCRViewer.Refresh();或者这样做,你在你的报表中写一些select的方法。
在启动的时候就过滤了,然后,你想要使用,就通过这样的语句去过滤一些表中的内容就是了。
我是动态创建试图,在试图创建程序里面使用SQL语句进行筛选。m_Report->put_SQLQueryString ((_bstr_t)"SELECT * FROM View");
这里进行字段选择也还是要在前面创建的View 基础上的!