我的代码有什么问题?我无法在浏览器中查看它。我搜索了google,但是没有找到答案。已经两天了,我正在寻找解决方案。有人能帮忙吗?谢谢。
public partial class WebForm1 : System.Web.UI.Page
{
string connectionString = "server=" +
ConfigurationManager.AppSettings["Server"] + ";uid=" +
ConfigurationManager.AppSettings["User ID"] + ";pwd=" +
ConfigurationManager.AppSettings["Password"] + ";database=" +
ConfigurationManager.AppSettings["Database Name"] +
";Command Timeout=28800;";
protected void Page_Load(object sender, EventArgs e)
{
EmpReport crystalReport = new EmpReport();
dsEmp ds = GetData();
crystalReport.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = crystalReport;
this.CrystalReportViewer1.RefreshReport();
}
private dsEmp GetData()
{
string query = "SELECT * FROM emp_table";
MySqlConnection con = new MySqlConnection(connectionString);
MySqlCommand cmd = new MySqlCommand(query);
MySqlDataAdapter da = new MySqlDataAdapter();
cmd.Connection = con;
da.SelectCommand = cmd;
dsEmp ds = new dsEmp();
da.Fill(ds, "DataTable1");
return ds;
}
}
1条答案
按热度按时间g9icjywg1#
通过将c://inetpub/wwwroot/aspnet\u client/system\u web中的4\u 0\u 30319文件夹放入我的项目的根文件夹,我可以显示crystal报表。还要确保在项目文件(web.config)中有正确的配置。