3
我正在創建一個水晶報表@ c#程序,但是當我首先執行報表時它的工作情況,但是當我第二次執行同樣的報表時,出現此錯誤。C#水晶報表參數超出範圍異常
我使用視圖來sql服務器來檢索我的數據。
cmd = new SqlCommand("Select * From referral where referralNo = '" +
lblReferral.Text + "' and clientNo = '" + cbClientNo.Text + "'", con);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
da.Fill(ds, "referral");
rp.SetDataSource(ds);
f3.crt.ReportSource = rp;
f3.Show();
rp.Close();
我有這個錯誤。
An unhandled exception of type 'System.ArgumentOutOfRangeException'
occurred in System.Windows.Forms.dll
Additional information: Index 0 is out of range.
那麼這些
CrystalReport1 rp = new CrystalReport1();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
reportViewer f3 = new reportViewer();
其中是創建報告實例('crt')?它是在設計時加入f3的控件嗎?嘗試獲取完整的異常調用堆棧並將其發佈到此處。 *通常暗示代碼不安全的腳本,用戶可以注入惡意代碼,如果在lblreferral或cbclientno中的文本是可編輯的* – dlatikay
感謝您的建議crt他們是水晶報告和f3是用於我使用的reportviewer的形式一個視圖來獲取所有這些數據,然後lblreferral是自動生成號碼,而cbclient是僅存儲clientno的組合框 –
確定您在第二次運行之前是否創建了一切的新實例,或者是否重新使用了現有實例? – dlatikay