المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Begginer's Crystal Report Problem



C# Programming
08-03-2011, 11:41 AM
hello guys... I am trying to get my first crystal report printed but seems to be having a problem I am unable to trace. I added a report to my (Windows Form) project, then added the dataset to it and finally added the following code. This does not show any error but does not show data either. Here is what I tried
private void Form1_Load(object sender, EventArgs e){ CrystalReportViewer crv = new CrystalReportViewer(); string ConnString = "Data Source=srv032k3; Initial Catalog= MuzeDB; User ID=muze; Password=saeedasd"; string query = "SELECT * FROM students"; try { SqlConnection conn = new SqlConnection(ConnString); SqlDataAdapter da = new SqlDataAdapter(query, ConnString); DataSet ds1 = new DataSet(); da.Fill(ds1, "students"); rpt.Load("D:\\Projects\\CrystalReportsApp\\Report\\StudentsReport.rpt"); rpt.SetDataSource(ds1); crystalReportViewer1.ReportSource = rpt; } catch (Exception ex) { MessageBox.Show("Something went wrong: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); }}