0

私はasp.net 2010でSap Crystal Reportを使用しています。実行時にレポートを更新するか、レポートビューアツールを使用して次のページに移動すると、エラーが表示さます。これが私のコーディングですno valid report source id available

 Dim crdoc5 As New ReportDocument()
 Dim crtablogoninfo5 As New TableLogOnInfo
 Dim crtabs5 As Tables

 If Not IsPostBack Then
      crdoc5.Load(Server.MapPath("CrStaffrecruit.rpt"))
      Session.Add("CrStaffrecruit", crdoc5)
      CrystalReportViewer5.ReportSource = crdoc5
  Else
      CrystalReportViewer5.ReportSource = Session("CrStaffrecruit")
  End If

  crdoc5.Load(Server.MapPath("CrStaffrecruit.rpt"))
  Dim crconninfo5 As New ConnectionInfo()
  rconninfo5.ServerName = "servername"
  crconninfo5.DatabaseName = "databasename"
  crconninfo5.UserID = "sa"
  crconninfo5.Password = ""

  crtabs5 = crdoc5.Database.Tables()
  For Each crtab5 As CrystalDecisions.CrystalReports.Engine.Table In crtabs5
      crtablogoninfo5 = crtab5.LogOnInfo
      crtablogoninfo5.ConnectionInfo = crconninfo5
      crtab5.ApplyLogOnInfo(crtablogoninfo5)
  Next

  CrystalReportViewer5.ReportSource = crdoc5
  CrystalReportViewer5.RefreshReport()

誰かが私を助けてくれることを知っていれば...事前に感謝します

4

5 に答える 5

1

次のコードは C# ですが、VB に変換するのはそれほど難しくなく、問題を解決するはずです。

protected void Page_Load(object sender, EventArgs e)
{
        if (Page.IsPostBack)
        {
            //whatever you do when the page is loaded for the first time
            //this could even be bindReport();
        }
        else
        {
            bindReport();
        }
}

public void bindReport()
{
        ReportDocument rptDoc = new ReportDocument();
        dsSample ds = new dsSample(); // .xsd file name
        DataTable dt = new DataTable();
        // Just set the name of data table
        dt.TableName = "Crystal Report Example";
        dt = getMostDialledNumbers(); //This function populates the DataTable
        ds.Tables[0].Merge(dt, true, MissingSchemaAction.Ignore);
        // Your .rpt file path will be below
        rptDoc.Load(Server.MapPath("yourReportFilePath.rpt"));
        //set dataset to the report viewer.
        rptDoc.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = rptDoc;
        CrystalReportViewer1.RefreshReport();
        //in case you have an UpdatePanel in your page, it needs to be updated
        UpdatePanel1.Update();
}
于 2012-05-15T13:06:53.677 に答える
1

これについては、次のリンクを参照してください

http://forums.sdn.sap.com/thread.jspa?messageID=10951477ᬵ

于 2012-01-02T07:51:19.777 に答える
0

次のリンクをたどってください。そのソリューションで同じ問題を解決しました。

http://www.aspsnippets.com/Articles/ASPNet-Crystal-Reports-13-Visual-Studio-2010-CrystalReportViewer-Search-Button-Issue---No-valid-report-source-is-available.aspx

于 2013-12-01T15:17:19.683 に答える
0

私はこの問題を何度か抱えています。解決策は、Report Document 変数をセッションに保存してからPage_load、以下のコードを挿入することです。

if (IsPostBack)
{
    if (Session["reportDocument"] != null)
    {
        ReportDocument cr = new ReportDocument();
        cr = (ReportDocument)Session["reportDocument"];
        CrystalReportViewer1.ReportSource = cr;
        CrystalReportViewer1.DataBind();
    }
}

(Session["reportDocument"])注意:に [表示] ボタンを入力することを忘れないでください。

于 2012-06-18T20:34:25.823 に答える
0

私は同じ問題を経験していました。投稿したコードをどのイベントで実行していますか? 多くのデバッグの後、コードを Page_Load に配置する必要があることがわかったのでお願いします (以前のように PreRender とは対照的に...)

お役に立てれば。

于 2011-07-11T19:05:40.727 に答える