Reputation: 71
I have a table tbl_invoice. I want to show crystal report of the data in this table. For every invoice, i have the invoiceid(primary key) and bill no. The primary key changes for every invoice but billno remains same. I am getting the billno of max invoiceid and passing it to crystal report. but it shows me only the last record in the crystal report.How to show all the records matching to the bill no? I wrote this code
private void button1_Click(object sender, EventArgs e)
{
SalesInvoice_Caret crt = new SalesInvoice_Caret();
crt.SetParameterValue("BillNo", txtBillNo.Text);
crystalReportViewer1.ReportSource = crt;
crystalReportViewer1.Refresh();
}
private void crt_sales_invoice_viewer_Load(object sender, EventArgs e)
{
string getBill = "Select top 1 BillNo from tbl_sales_invoice order by SalesInvoiceId desc";
SqlCommand cmd = new SqlCommand(getBill, con);
con.Open();
object obj = cmd.ExecuteScalar();
con.Close();
MessageBox.Show(obj.ToString());
txtBillNo.Text = obj.ToString();
}
Upvotes: 0
Views: 1132
Reputation: 1708
I think that you need to pass all the invoiceid numbers and wanted data when creating the "SalesInvoice_Caret" object. Create a query that brings all the invoiceid numbers for the selected bill no. and pass the data to the report. In the report, you need to use the group expert to create a specific report for each invoiceid-billno pair.
Upvotes: 0