2 回答

TA貢獻1804條經驗 獲得超7個贊
如果您的目標是從 SQL 填充數據,則可以通過 rpt 文件設置連接,方法是在任務欄上選擇Database > Database Expert > OLE DB (ADO)(如果是 MS SQL)> SQL Server Native Clinet。以這種方式建立的連接也將在評估報告時使用,因此您不需要每次都通過它。

TA貢獻1982條經驗 獲得超2個贊
早上好朋友們 我修改了我的代碼以避免詢問參數。我刪除了 cryRpt.Dispose() 和 cryRpt.Close()。它有效,但我決定將這些代碼行放在 winform 關閉事件中。我的代碼是:
public FrmReport()
{
InitializeComponent();
rpDoc = new ReportDocument();
crvReportes.AllowedExportFormats = (int)(ViewerExportFormats.ExcelFormat | ViewerExportFormats.PdfFormat| ViewerExportFormats.WordFormat);
}
private void LoadReport()
{
try
{
rpDoc.Load((Application.StartupPath + "\\rpExclu.rpt").Replace("\\bin\\Debug", ""));
rpDoc.SetParameterValue("@IDA", this.ida);
rpDoc.SetDatabaseLogon(this.us, this.pass);
crvReportes.ReportSource = rpDoc;
crvReportes.Refresh();
}
catch (Exception ex)
{
crvReportes.Refresh();
XtraMessageBox.Show("" + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FrmReporteBienes_FormClosing(object sender, FormClosingEventArgs e)
{
if (rpDoc.IsLoaded)
{
rpDoc.Dispose();
rpDoc.Close();
}
}
這是最好的解決方案嗎?好吧,在這一刻它起作用了。提前致謝。
- 2 回答
- 0 關注
- 166 瀏覽
添加回答
舉報