0
我是Crystal Reports的新手将数据源绑定到Crystal Reports
Crystal Viewer首先显示数据表而不是给出数据源,并且每次都需要刷新Crystal Viewer。
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
string str = ConfigurationManager.ConnectionStrings["ConnData"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(str);
string cellno = LoginUser.CellNo;
SqlCommand cmd = new SqlCommand("SP_Get_CustomerByCellNo", con);
cmd.Parameters.AddWithValue("@Cell", cellno);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
int i = dt.Rows.Count;
ReportDocument rd = new ReportDocument();
ConnectionInfo info = new ConnectionInfo();
info.DatabaseName = "BillingAndAccounts";
info.UserID = "sa";
info.Password = "sa123";
rd.VerifyDatabase();
rd.Load(@"C:\Users\Abhinavu\Documents\Login\Login\OrderWindow.rpt");
rd.SetDataSource(dt);
crystalReportViewer1.ReportSource = rd;
}
我有一些问题,你已了解正在尝试什么去做。从代码中为报告设置连接信息以使用其上的查询,并尝试将数据源传递给报告。您使用什么类型的数据源来开发报告,OLEDB,ADO.net,...? – Raphael
正在使用连接信息查询来设置从数据库连接到Crystal Viewer.Yes我想通过数据源报告...并且正在使用ADO .net .... – user3432576
请解决问题.... – user3432576