如何解决无法使用 C# 从 Crystal Report 中的数据集 (XML) 检索数据
我正在构建一个应用程序 (c#),它显示包含来自 sql DB 的数据的报告。它正在我的电脑上工作。我正在使用水晶报告来显示带有 xml 架构的报告。 数据集工作正常,但是当我发布应用程序并将其安装在其他计算机上时,应用程序无法找到数据集(xml),因为它的默认位置是根据我的主计算机设置的。 有人可以帮我设置应用程序自动从计算机上查找数据集,以及安装应用程序的新位置。
我使用的是 Visual Studio 2019 with.0 fmw。下面是我的代码:
{
string myconstring = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;
SqlConnection con1 = new SqlConnection(myconstring);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("CustId",typeof(string));
dt.Columns.Add("CustName",typeof(string));
dt.Columns.Add("Total",typeof(decimal));
foreach(DataGridViewRow dgv in dgv_max_purchase.Rows)
{
dt.Rows.Add(dgv.Cells[0].Value,dgv.Cells[1].Value,dgv.Cells[2].Value);
}
ds.Tables.Add(dt);
ds.WriteXmlSchema("xml_file_name.xml");
Report rpt = new Report();
CrystalReport1 crt = new CrystalReport1();
TextObject text = (TextObject)crt.ReportDefinition.Sections["Section1"].ReportObjects["text24"];
TextObject text1 = (TextObject)crt.ReportDefinition.Sections["Section1"].ReportObjects["text25"];
TextObject text2 = (TextObject)crt.ReportDefinition.Sections["Section1"].ReportObjects["text26"];
text.Text = Convert.ToString(dtfrom.Value);
text1.Text = Convert.ToString(dtto.Value);
text2.Text = lb_branch.Text;
crt.SetDataSource(ds);
rpt.crystalReportViewer1.ReportSource = crt;
rpt.crystalReportViewer1.Refresh();
rpt.Show();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。