本文介绍了错误:(object)是一个''字段''但是像''type''一样使用(crystalreport和C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据txtInvoiceNo中的发票编号在报告中显示发票详细信息,但我在行中的crystalReportViewer1中面临错误// crystalReportViewer1 r = new crystalReportViewer1(); //
I want to show the invoice details in the report i have made, as per the invoice number in the txtInvoiceNo, but i am facing an error under "crystalReportViewer1 in the line //crystalReportViewer1 r = new crystalReportViewer1(); //
using System;
using System.IO;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using System.Data.OleDb;
using System.Collections;
using System.Web;
namespace WStoreSystem
{
public partial class Print : Form
{
public Print()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void find_Click(object sender, EventArgs e)
{
if (txtInvoiceNo.Text == "")
{
MessageBox.Show("Please insert the invoice number!");
txtInvoiceNo.Focus();
}
else
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|StoreSys.mdb");
OleDbDataAdapter ad = new OleDbDataAdapter("select * from InvoiceDetails where InvoiceID=@InvoiceID", con);
ad.SelectCommand.Parameters.Add("@InvoiceID", OleDbType.VarChar);
ad.SelectCommand.Parameters["@InvoiceID"].Value = txtInvoiceNo.Text;
DataSet ds = new DataSet();
ad.Fill(ds, "InvoiceDetails");
crystalReportViewer1 r = new crystalReportViewer1();// the error is here
r.SetDataSource(ds.Tables["InvoiceDetails"]);
crystalReportViewer1.ReportSource = r;
}
}
}
推荐答案
这篇关于错误:(object)是一个''字段''但是像''type''一样使用(crystalreport和C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!