错误:(object)是一个''字段''但是像''type''一样使用(crystalreport和C#) [英] Error: (object) is a ''field'' but is used like a ''type'' ( crystalreport and C# )
本文介绍了错误:(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;
}
}
}
推荐答案
好吧,你没告诉我们错误是什么,所以我们可以猜测(提示 - 修改你的问题)
你有安装Crystal Reports / Viewer吗?在您的开发机器上?
顺便说一句,这是 http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-stepbystep.htm [ ^ ]似乎是使用Crystal的开始 - 你拖了一个实例Crsytal Report Viewer控件到您的表单上?
Well, you don't tell us what the error is, so we can but guess (hint - modify your question)
Do you have Crystal Reports/Viewer installed on your Dev machine ?
btw, this http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-stepbystep.htm[^] seems to be a start on using Crystal - have you dragged an instance of the Crsytal Report Viewer control onto your form ?
crystalReport1 r = new crystalReport1();
crystalReport1 r = new crystalReport1();
这篇关于错误:(object)是一个''字段''但是像''type''一样使用(crystalreport和C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文