我一直在使用Crystal报告。我一直在开发Windows窗体中的库存系统。Crystal Report未显示来自Dataset的任何数据
因为我得从不同的表中的数据在Crystal Reports,所以我做了自定义的数据集和我需要的行填充它,如下所示:
代码:
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;
图片CR设计报告:
自定义数据集的图片:
数据集填充图像
空报告
问题: 因为一切都很完美。为什么我的数据不会显示在报告中?
你好吗任何错误消息的形式?数据库和DataTable匹配的数据类型? – Prashanth
dataType完全匹配。没有遗漏。 – Umar