2012-03-16 199 views
0

如果您請幫我解決問題,我正在嘗試創建一個水晶報表,頁面背後的代碼如下所示......當我運行應用程序時,網頁加載了幾個小時而沒有任何結果。 ...crystal reports sap .net

namespace WebApplication11 

{ 
    public partial class About : System.Web.UI.Page 
    { 
     //  Below is the final code for reports. 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      ReportDocument rptDoc = new ReportDocument(); 
      DataSet1 ds = new DataSet1(); // .xsd file name 
      DataTable dt = new DataTable(); 
      // Just set the name of data table 
      dt.TableName = "db.Customer_Orders"; 
      dt = getAllOrders(); //This function is located below this function 
      ds.Tables[0].Merge(dt); 
      // Your .rpt file path will be below 
      rptDoc.Load(Server.MapPath("c:/users/dell/documents/visual studio 2010/Projects/WebApplication11/WebApplication11/CrystalReport1.rpt")); 
      //set dataset to the report viewer. 
      rptDoc.SetDataSource(ds); 
      CrystalReportViewer1.ReportSource = rptDoc; 
     } 
     public DataTable getAllOrders() 
     { 
      //Connection string replcae 'databaseservername' with your db server name 
      string sqlCon = "User ID=User-PC;PWD=; server=USER-PC/SQLEXPRESS;INITIAL CATALOG=SampleDB;PERSIST SECURITY INFO=FALSE;Connect Timeout=0"; 
      SqlConnection Con = new SqlConnection(sqlCon); 
      SqlCommand cmd = new SqlCommand(); 
      DataSet ds = null; 
      SqlDataAdapter adapter; 
      try 
      { 
       Con.Open(); 
       //Stored procedure calling. It is already in sample db. 
       cmd.CommandText = "getAllOrders"; 
       cmd.CommandType = CommandType.StoredProcedure; 
       cmd.Connection = Con; 
       ds = new DataSet(); 
       adapter = new SqlDataAdapter(cmd); 
       adapter.Fill(ds, "Users"); 
      } 
      catch (Exception ex) 
      { 
       throw new Exception(ex.Message); 
      } 
      finally 
      { 
       cmd.Dispose(); 
       if (Con.State != ConnectionState.Closed) 
        Con.Close(); 
      } 
      return ds.Tables[0]; 
     } 



    } 
} 
+0

您是否嘗試過手動運行存儲過程?這種比較需要多長時間? – 2012-03-16 02:02:54

+0

您是否嘗試將調試器附加到工作進程以查看其被阻止的位置? – Tung 2012-03-16 03:34:46

回答

0

我覺得你似乎CrystalReportViewer1.ReportSource = rptDoc;後缺少一個行:

crystalReportViewer1.Refresh();

但作爲東所述 - 附加一個斷點,步進式,看看它卡住。