每月报告代码使用水晶报告时出错? [英] Error in monthly report code use of crystal report?

查看:80
本文介绍了每月报告代码使用水晶报告时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作按钮点击事件的月度报告,并通过水晶报告显示。

tc_np =标签控制名称

tbprint =标签名称我放了crystalreportviewer。

mnt =是水晶报告,我根据patient_info的表定义或设计

crv =是crystalreportviewer名称。



  private   void  mntbtn_Click( object  sender,EventArgs e)
{
tc_np.SelectedTab = tbprint;
尝试
{
cn.Open();
DataSet ds2 = new DataSet();
// SELECT * FROM MyTable WHERE DATEDIFF(mm,MyDateColumn,GETDATE())= 0
mnt m = new mnt();
OleDbCommand cmdmnt = new OleDbCommand( select *来自patient_info,其中DATEDIFF(m,E_date,DATE())= 0,cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmdmnt);
da.Fill(ds2, patient_info);
m.SetDataSource(ds2.Tables [ patient_info]);
crv.ReportSource = m;
crv.RefreshReport();
cn.Close();
}
catch (例外p)
{
MessageBox.Show(p.Message, error,MessageBoxButtons.OK,MessageBoxIcon.Error);
}

}





错误:

 da。填写(ds2,& quot; patient_info& quot;)



错误:没有给出一个或多个必需参数的值

< b>



我的尝试:



i在date()中尝试了chages,为Datediff(mm,E_date,Date())= 30等提供条件。

解决方案

如果您的DBMS是SQL Server然后尝试 GETDATE()而不是 DATE(),因为没有这样的功能。 GETDATE()用于获取数据库服务器的当前日期。

 OleDbCommand cmdmnt =  new  OleDbCommand (  select * from patient_info其中DATEDIFF(m,E_date,GETDATE())= 0,cn ); 





希望,它有帮助:)

如果我在这里错过了什么,请告诉我。


I want to make monthly report on button click event and display through crystal report.
tc_np = tab control name
tbprint = tab name where i put crystalreportviewer.
mnt = is crystal report where i define or design according table of patient_info
crv = is crystalreportviewer name.

private void mntbtn_Click(object sender, EventArgs e)
        {
            tc_np.SelectedTab = tbprint;
            try
            {
                cn.Open();
                DataSet ds2 = new DataSet();
                //SELECT * FROM MyTable WHERE DATEDIFF(mm, MyDateColumn, GETDATE()) = 0
                mnt m = new mnt();
                OleDbCommand cmdmnt = new OleDbCommand("select * from patient_info where DATEDIFF(m, E_date, DATE())=0",cn);
                OleDbDataAdapter da = new OleDbDataAdapter(cmdmnt);
                da.Fill(ds2, "patient_info");
                m.SetDataSource(ds2.Tables["patient_info"]);
                crv.ReportSource = m;
                crv.RefreshReport();
                cn.Close();
            }
            catch (Exception p)
            {
                MessageBox.Show(p.Message,"error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }

        }



error at:

da.Fill(ds2, &quot;patient_info&quot;)


error: "no value given for one or more required parameters"


What I have tried:

i tried chages in date(), give condition for as Datediff(mm,E_date,Date())=30, and etc.

解决方案

If your DBMS is SQL Server then try GETDATE() instead of DATE(), because there is no such function. GETDATE() is used to get the current date of the DB server.

OleDbCommand cmdmnt = new OleDbCommand("select * from patient_info where DATEDIFF(m, E_date, GETDATE())=0",cn);



Hope, it helps :)
Please let me know if I am missing something here.


这篇关于每月报告代码使用水晶报告时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆