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