Crystal reports with C#, Displays a error message.
-
Hi , I am trying to display a crystal report using the crystal report viewer in vs 2008,and it does not display instead it gives a database login screen. This is the code which I am using . ================================================================== CrystalReport1 objRpt; //Usermaster objRpt; objRpt = new CrystalReport1(); string connstr = "Persist Security Info=False;userid=btssys; password=xx23;database=bts;server=xxxx"; MySqlConnection mc = new MySqlConnection(connstr); try { mc.Open(); string sql = "select userid, usergiven,userfamily,status,expiry,created,created_by from user_master"; MySqlCommand cmd = new MySqlCommand(sql, mc); MySqlDataAdapter adp = new MySqlDataAdapter(sql, mc); //new MySqlDataAdapter( DataSet ds = new DataSet(); int li_rows = adp.Fill(ds, "myds"); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("No data Found", "CrystalReportWithmysql"); return; } // Setting data source of our report object objRpt.SetDataSource(ds); // Binding the crystalReportViewer with our report object. crystalReportViewer1.ReportSource = objRpt; ================================================================================ If I debug I can find that the ds is retrieving the rows. But nothing comes up on the crystal report viewer.It displays a database login screen instead with server name as myds. Is this something to do with Mysql or something wrong with VS 2008 or crystal report coding. Thanks
-
Hi , I am trying to display a crystal report using the crystal report viewer in vs 2008,and it does not display instead it gives a database login screen. This is the code which I am using . ================================================================== CrystalReport1 objRpt; //Usermaster objRpt; objRpt = new CrystalReport1(); string connstr = "Persist Security Info=False;userid=btssys; password=xx23;database=bts;server=xxxx"; MySqlConnection mc = new MySqlConnection(connstr); try { mc.Open(); string sql = "select userid, usergiven,userfamily,status,expiry,created,created_by from user_master"; MySqlCommand cmd = new MySqlCommand(sql, mc); MySqlDataAdapter adp = new MySqlDataAdapter(sql, mc); //new MySqlDataAdapter( DataSet ds = new DataSet(); int li_rows = adp.Fill(ds, "myds"); if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("No data Found", "CrystalReportWithmysql"); return; } // Setting data source of our report object objRpt.SetDataSource(ds); // Binding the crystalReportViewer with our report object. crystalReportViewer1.ReportSource = objRpt; ================================================================================ If I debug I can find that the ds is retrieving the rows. But nothing comes up on the crystal report viewer.It displays a database login screen instead with server name as myds. Is this something to do with Mysql or something wrong with VS 2008 or crystal report coding. Thanks
Hi all, I resolved it myself, change the DataSet ds = new DataSet(); int li_rows = adp.Fill(ds, "myds"); I used a datatable and changed the retrieval to adp.fille(dt) ; objRpt.SetDataSource(dt); and it works any ways, thanks everyone.