Ich habe seit langer Zeit Crystal Reports verwendet. Ich hatte ein Inventory-System in Windows-Formularen entwickelt.Crystal Report Keine Daten aus dem Dataset
Da ich Daten aus verschiedenen Tabellen bekommen in Crystal Reports, so habe ich benutzerdefinierte Datensatz machte es mit meinem erforderlichen Zeilen wie folgt gefüllt:
Code:
cmd = new SqlCommand();
SqlDataAdapter myDA = new SqlDataAdapter();
CustomDataSet myDS = new CustomDataSet();
con = new SqlConnection(cs.DBConn);
cmd.Connection = con;
//receipt code goes here
string query = "select Customer.CustomerName as Name,Customer.Address as Address,Customer.ContactNo as ContactNo, Product.ProductName as ItemName, ProductSold.Quantity as Quantity, Invoice_Info.InvoiceNo as InvoiceNumber, ProductSold.Price as PriceOfItem, ProductSold.Tax as TaxOnItem, ProductSold.Discount as DiscountOnItem, Invoice_Info.TotalPayment as PaidAmount, Invoice_Info.SoldBy as Salesman, Invoice_Info.CashedBy as Cashier, Invoice_Info.DiscountAmount as DiscountOnInvoice, Invoice_Info.PaymentType as PaymentType from Invoice_Info,Product,ProductSold,Customer where Invoice_Info.CustomerID=Customer.CustomerId and Invoice_Info.InvoiceNo=ProductSold.InvoiceNo and ProductSold.ProductID=Product.ProductId and Invoice_Info.InvoiceNo=" + txtInvoiceNo.Text;
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
myDA.SelectCommand = cmd;
myDA.Fill(myDS.Invoice);
//if customer is walking customer show change else show credit of regular customer
if (txtCustomerName.Text == Constants.WalkingCustomer)
{
for (int i = 0; i < myDS.Invoice.Count; i++)
{
myDS.Invoice[i].Balance = double.Parse(txtTotal.Text) - double.Parse(txtTotalPayment.Text);
}
}
//filling company informtation
myDS.Company.AddCompanyRow(Company.Name, Company.Address, Company.Phone);
rptReceipt rpt = new rptReceipt();
rpt.SetDataSource(myDS);
frmInvoiceReport frm = new frmInvoiceReport();
frm.crystalReportViewer1.ReportSource = rpt;
frm.crystalReportViewer1.RefreshReport();
frm.Visible = true;
Bild von CR entworfen Bericht:
Bild Custom Datensatz:
Dataset gefüllt Bild
leeren Bericht
Frage: Da ist alles perfekt. Warum werden meine Daten nicht im Bericht angezeigt?
ein Formular anzuzeigen sind Sie eine Fehlermeldung bekommen? Passt der DataType aus Ihrer Datenbank und DataTable? – Prashanth
Der Datentyp stimmt perfekt überein. Nichts fehlt. – Umar