Crystal报表中无效的报表文件路径 [英] Invalid report file path in crystal report
问题描述
我正在使用csharp代码在asp.net中进行小型应用程序.
设计如下;
I am doing small application in asp.net with csharp code.
Design as follows;
Employee id
Name
DOB
Age
Address
Mobile
Phone No
所有数据都存储在数据库中.
当我运行所有员工详细信息时,我也在使用Crystal Report Viewer.
我有一个文本框和一个按钮(按钮名称是运行报告"),在文本框中键入特定的Employee ID,然后单击按钮(运行复制").我希望特定的员工详细信息希望出现在晶状体报告查看器的运行模式中.当我键入特定的员工ID并单击按钮时.
我有以下错误,如下所示无效的仓库文件路径.请帮助我并发送代码.
按以下方式运行Reprot Button代码;
All the datas are stored in the database.
I am also using crystal report viewer when i run all the employee details are appear in the run mode.
I have one textbox and one button(Button name is Run Report), in the textbox i type the particular Employee id and clik the button(Run Reprot). I want particular employee details want to appear in the run mode in crysal report viewer. When I type particular employee id and click the button.
I have following errors as follows invalid repot file path.please help me and send the code.
Run Reprot Button code as follows;
protected void Button5_Click(object sender, EventArgs e)
{
con = new SqlConnection("Server=(local);initial catalog=master;Trusted_Connection=True");
con.Open();
string str = "select * from Empdet where EmployeeID='" + DropDownList1.SelectedValue + "'";
SqlCommand com = new SqlCommand(str, con);
SqlDataAdapter sqlda = new SqlDataAdapter(com);
DataSet ds = new DataSet();
sqlda.Fill(ds, "Empdet");
con.Close();
ReportDocument r1 = new ReportDocument();
//r1.Load("Full Path of Your Report\Employee.rpt");
r1.SetDataSource(ds);
CrystalReportViewer1.ReportSource = r1;
CrystalReportViewer1.RefreshReport();
}
推荐答案
尝试一下:
Try This:
ReportDocument cr = new ReportDocument();
String path=Server.Mappath("Reports/rtp.rpt");
cr.Load(path);
cr.SetDataSource(ds);
CrystalReportViewer1.ReportSource = cr;
CrystalReportViewer1.DataBind();
谢谢
Thanks
这篇关于Crystal报表中无效的报表文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!