如何通过在Crystal Reports中传递参数从两个表中获取数据 [英] How Do I Obtain The Data From Two Tables By Passing A Parameter In Crystal Reports

查看:52
本文介绍了如何通过在Crystal Reports中传递参数从两个表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#windows应用程序中,我试图从两个表中获取我的水晶报告中的数据,但遗憾的是它没有向我显示记录我设计我的报告以显示凭证数据,因为我在文本框中键入凭证代码并且点击查看报告然后我没有得到任何结果



这是我从两张桌子加载数据的代码



In C# windows application I tried to obtain the data on my crystal report from two tables but unfortunately it doesn't shows the record to me I design my report to show vouchers data as I type the voucher code in a text box and click on view report then I don't get any result

Here is my code to load the data from two tables

OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConString"].ToString());
        OleDbCommand com;
        OleDbDataAdapter adp = new OleDbDataAdapter();
        DataSet ds = new DataSet();

        public Form1()
        {
            InitializeComponent();
        }
        private void btn_view_Click(object sender, EventArgs e)
        {
            if (txt_vc_code.Text == "")
            {
                MessageBox.Show("Enter Voucher Code");
            }
            else
            {
                //ds.Tables[0].Rows.Clear();
                //ds.Tables["payment_voucher,Branch_Master"].Rows.Clear();
                adp = new OleDbDataAdapter("select p.*,b.* from payment_voucher as p inner join Branch_Master as b on b.branch_code =p.branch_code where p.voucher_code='" + txt_vc_code.Text + "'", con);
                DataSet ds2 = new DataSet();
                adp.Fill(ds2, "payment_voucher,Branch_Master");
                ReportDocument rd = new ReportDocument();
                rd.Load("E:\\Vertex_app\\VertexApp\\VertexApp\\Payment_Voucher_rpt.rpt");
                rd.SetDataSource(ds.Tables["payment_voucher,Branch_Master"]);
                crystalReportViewer1.ReportSource = rd;
            }
        }
        private void Form1_Load(object sender, EventArgs e)        {
            CrystalAddData();
        }
        public void CrystalAddData()
        {
            adp = new OleDbDataAdapter("select p.*,b.* from payment_voucher as p inner join Branch_Master as b on b.branch_code =p.branch_code", con);
            adp.Fill(ds);
            ReportDocument rd = new ReportDocument();
            rd.Load("E:\\Vertex_app\\VertexApp\\VertexApp\\Payment_Voucher_rpt.rpt");
            rd.SetDataSource(ds.Tables["payment_voucher,Branch_Master"]);
            crystalReportViewer1.ReportSource = rd;
        }





请帮我找到并解决这个错误提前感谢你们所有



Please help me to find and solve this error Thanks in advance to you all

推荐答案

在水晶报告中使用存储过程。并从c#
use store procedure in crystal report. And call store procedure from c#


这篇关于如何通过在Crystal Reports中传递参数从两个表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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