Click here to Skip to main content
16,016,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Comments
George Jonsson 3-Oct-14 6:04am    
Solve what error?
Omkar Hendre 3-Oct-14 6:22am    
I am not getting the data on a report and i dont get any error aslo but I want to show the particular vouchers data on report by passing the voucher code
Omkar Hendre 3-Oct-14 6:35am    
i design the report but i don't know to upload the picture of report

1 solution

use store procedure in crystal report. And call store procedure from c#
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900