"加载报告失败"。在胜利申请中

时间:2015-07-05 11:15:43

标签: c# visual-studio-2010

此代码在VS2010中运行良好。但是,当我创建此项目的.exe文件时,无法通过显示错误消息加载报告文件"加载报告失败"。

SqlCommand cmd = new SqlCommand();
cmd.Connection = ClassSession.con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "SPPrintRequest";
SqlParameter reqid = new SqlParameter("@ReqID", textBox2.Text);
cmd.Parameters.Add(reqid);
SqlDataAdapter dataadapter = new SqlDataAdapter();
dataadapter.SelectCommand = cmd;
DataSet ds = new DataSet();
dataadapter.Fill(ds);
ConnectionInfo connectionInfo = new ConnectionInfo();
ReportDocument RepDoc = new ReportDocument();
connectionInfo.ServerName = ".";
connectionInfo.DatabaseName = "database";
string RepPath = Application.StartupPath + "\\ReportRequest.rpt";
RepDoc.Load(RepPath);
RepDoc.SetDataSource(ds);
Program.frmprintreq.crystalReportViewer1.ReportSource = RepDoc;
ParameterValues parameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = textBox2.Text;
parameterValues.Add(parameterDiscreteValue);
ParameterFieldDefinitions parameterFieldDefinitions = RepDoc.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions["@ReqID"];
parameterFieldDefinition.ApplyCurrentValues(parameterValues);

0 个答案:

没有答案