, если вы мне поможете, я пытаюсь создать отчет Crystal, а код позади страницы выглядит следующим образом ... когда я запускаю приложение, веб-страница загружается часами без результата ....
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];
}
}
}