我正在使用 SQL Server 数据库在 C# 中使用 Crystal Reports,我无法继续我的项目,因为我遇到了错误
加载保存报告异常
在我要设置我的水晶报表的数据源的那一行。
任何帮助将不胜感激。
这是我的代码:
SqlConnection con = new SqlConnection();
string conString = @"data source =JR-PC\SQLEXPRESS;initial catalog = election;integrated security =true;";
string sql = "Select can_names,can_pos,partylist,num_votes from tbl_Candidates";
con = new SqlConnection(conString);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, con);
ReportPracice._DATASETS.DataSet1 ds = new ReportPracice._DATASETS.DataSet1();
da.Fill(ds, "tbl_Candidates");
MessageBox.Show(ds.Tables[1].Rows.Count.ToString()); //Returns a value of "40";
con.Close();
ReportPracice._REPORTS.CrystalReport1 rpt = new ReportPracice._REPORTS.CrystalReport1();
rpt.SetDataSource(ds.Tables[1]); //in this line, where I am getting that error.
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.Refresh();