1

このコードを使用して VS2010 でクリスタル レポートを開いていますaxCRViewer1crystal report viewer control name、この行でエラーが発生しています

axCRViewer1.ReportSource = rptDoc;

どうすれば修正できますか?

private void ViewR_Load(object sender, EventArgs e)
            {
                ReportDocument rptDoc = new ReportDocument();
                DataSetPatient ds = new DataSetPatient(); // .xsd file name
                DataTable dt1 = new DataTable();
                DataTable dt = DBHandling.GetPatient();//getting data using GetPatient()

                // Just set the name of data table
                dt.TableName = "Crystal Report P";
                ds.Tables[0].Merge(dt);

                // Your .rpt file path will be below
                rptDoc.Load("C:\\Users\\Monika\\Documents\\Visual Studio 2010\\Projects\\SonoRepo\\SonoRepo\\Reports\\CrystalReportP.rpt");

                //set dataset to the report viewer.
                rptDoc.SetDataSource(ds);
                axCRViewer1.ReportSource = rptDoc;//getting error at this line 
                // code to get data from the DB           
            }

Getpatient() コード

public static DataTable GetPatient()
        {
            DataTable patientTable = new DataTable();
            using (OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=sonorepo.mdb"))
            {
                using (OleDbDataAdapter da = new OleDbDataAdapter(@"SELECT PatientID,PFirstName FROM Patient_Registration", con))
                    da.Fill(patientTable);
            }
            return patientTable;
        }
4

2 に答える 2

0

このメッセージはデータから来ています。DataTable dt の構造が DataSetPatient の最初のテーブルの構造と同じかどうかを確認します。

DataSetPatient のコードを置き換えることもできます。

DataSetPatient ds = 新しい DataSetPatient(); // .xsd ファイル名 .... ds.Tables[0].Merge(dt);

DataSet ds = new Dataset() ds.Tables.Add

于 2013-09-27T16:57:43.087 に答える
0

これが私のために働いたものです:

64 ビット マシンにインストールする場合は、[ビルド] タブのアプリケーション プロパティでプラットフォーム ターゲットとして [任意の CPU] が選択されていることを確認し、オプションがある場合は [32 ビットを優先] のチェック ボックスをオフにします。Crystal は 32/64 ビット アセンブリに非常に敏感で、トラブルシューティングが非常に困難なかなり直観に反する仮定を立てています。

于 2016-03-11T17:19:51.123 に答える