[英]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];
}
}
}
我認為您在CrystalReportViewer1.ReportSource = rptDoc;
之后似乎缺少一行CrystalReportViewer1.ReportSource = rptDoc;
:
crystalReportViewer1.Refresh();
但是,正如董先生所說的那樣-附加一個斷點並逐步查看它被卡在哪里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.