如何使用wpf应用程序在当前目录中加载水晶报表? [英] How to load crystal report in current directory using wpf application?
本文介绍了如何使用wpf应用程序在当前目录中加载水晶报表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我正在使用此代码,但加载失败错误给出: -
SqlConnectionClass conString = new SqlConnectionClass();
SqlCommand cmd = new SqlCommand( procGeneratePDF ,conString.GetConnection());
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add( @ InvoiceNumber,SqlDbType.Int).Value = InvoiceNum;
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ReportDocument InvoiceReportDocument = new ReportDocument();
InvoiceReportDocument.Load(AppDomain.CurrentDomain.BaseDirectory + \\ + < span class =code-string> @ \\abc.rpt); \\加载报告失败..
InvoiceRep.SetDataSource(ds);
请帮帮我,我的rpt文件不在bin \debug目录中。
我的文件放在应用程序目录中。
我已经直接添加了水晶报告。
请帮我,怎么能加载水晶报告?
先谢谢。
Ankit Agarwal >
软件工程师
解决方案
我会告诉你我是如何用水晶报告解决我的问题可能对你有用....
首先你需要在visual studio中创建水晶报告并设置构建动作=内容
右击水晶报告然后选择导出数据库
所以从sql_server拖动所有数据
并更改目录我能找到的唯一解决方案是使用
[text.config] file
并设置此代码
< appsettings>
< add key = crystala value = C:\\Users \\\\
ormal\\Desktop \ \its done \\IDcardproject \\ WindowsFormsApplication1 \\CrystalReport1.rpt />
< add key = crystalb value = C:\\Users \\\\
ormal\\\ \\Desktop \\its done \\IDcardproject \\ WindowsFormsApplication1 \\CrystalReport2.rpt />
< / appsettings >
希望对您有所帮助..
如果不清楚请告诉我,
Hello,
I am using this code but load failed error its giving:-
SqlConnectionClass conString = new SqlConnectionClass();
SqlCommand cmd = new SqlCommand("procGeneratePDF", conString.GetConnection());
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@InvoiceNumber", SqlDbType.Int).Value = InvoiceNum;
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds);
ReportDocument InvoiceReportDocument = new ReportDocument();
InvoiceReportDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "\\" + @"\\abc.rpt"); \\ Load report failed..
InvoiceRep.SetDataSource(ds);
Please help me, my rpt file its not in the bin\debug directory.
my file put in the application directory.
I have directly added crystal report.
Please help me, how can load crystal report?
Thanks in Advance.
Ankit Agarwal
Software Engineer
解决方案
i will tell you how i did solved my problem with crystal report may it be useful for you....
in first you have to create crystal report in visual studio and set build action =content
right click on crystal report and then chose "export database"
so drag all data from sql_server
and to change directory the only solution i could find it was using
[text.config] file
and set this code
<appsettings> <add key="crystala" value="C:\\Users\\normal\\Desktop\\its done\\IDcardproject\\WindowsFormsApplication1\\CrystalReport1.rpt" /> <add key="crystalb" value="C:\\Users\\normal\\Desktop\\its done\\IDcardproject\\WindowsFormsApplication1\\CrystalReport2.rpt" /> </appsettings>
hope be helpful ..
and if it not clear let me know ,,
这篇关于如何使用wpf应用程序在当前目录中加载水晶报表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文