Hi all, im student, actually writing a sqlite database winform applications and i need to generate some reports. Im using crystal reports and vs2008. In my applications i got combobox and after selecting and clicking on a button i want to generate a report with details of selected item from combobox. How to design report (adding and naming textboxes and so) to work with this code?
code in constructor of form
conn = new SQLiteConnection(@"data source=db.s3db"); conn.Open(); string select = "select idpod, menopriezvisko||', '||obec as meno from podielnici"; data = new SQLiteDataAdapter(select, conn); data.Fill(dataSet1); comboBox1.DataSource = dataSet1.Tables[0]; comboBox1.DisplayMember = "meno"; comboBox1.ValueMember = "idpod";
code in onclick button event
string id = comboBox1.SelectedValue.ToString(); DataTable tab = new DataTable("table"); tring select = "select idpod, menopriezvisko, ulica, obec, PSC, narodenie from podielnici where idpod='" + id + "'"; conn = new SQLiteConnection(@"data source=db.s3db"); data = new SQLiteDataAdapter(select, conn); data.Fill(tab); Form1 frm = new Form1(tab); frm.ShowDialog(); this.Close();
and constructor of form with crystal report viewer
CrystalReport1 rprt = new CrystalReport1(); string file = @"MySchema.xml"; DataSet ds = new DataSet(); ds.Tables.Add(tab); ds.WriteXmlSchema(file); rprt.Load(file,CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy); rprt.SetDataSource(tab); * crystalReportViewer1.ReportSource = rprt;
can you pls help me with this problem? i always get error "The report has no tables." at line with asterix