Programming for Everybody: November 2024

Simple and Effective: Creating Invoices with Crystal Reports in C# With Source code

Source Code:
 SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=products;Integrated Security=True");
            conn.Open();
            SqlCommand cmd = new SqlCommand("Select * From View_3 Where n_invoice=@n_invoice", conn);
            cmd.Parameters.AddWithValue("n_invoice", textBox1.Text.Trim());
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            dt.Clear();
            da.Fill(dt);
            conn.Close();
            CrystalReport1 report = new CrystalReport1();
            report.SetDataSource(dt);
            crystalReportViewer1.ReportSource = report;
            crystalReportViewer1.Refresh();