Atul Rokade

Atul Rokade

  • NA
  • 141
  • 43.9k

How to show data in crystal report without using database

Jun 18 2016 12:12 PM
Hi all,
 
Iam creating one medical application in that application i have four textboxes and one datagridview in form(1) and Crystal report in form(2)
 
iam passing data from form(1) to form(2) but when i run the application its showing me exception that  Input string was not in a correct format.Couldn't store <18  /06  /2016> in Quantity Column. Expected type is Int32. in  dt.Rows.Add(msktextdate.Text, txtname.Text, txtdoctorname.Text, txtaddress.Text); this line 
 
Quantity column is in datagridview but still it showing me above error here im paste my all form(1) and form(2) code
 
form(1):
 
public void createrow()
{
if (dt.Rows.Count <= 0)
{
DataColumn dc1 = new DataColumn("Quantity", typeof(int));
DataColumn dc2 = new DataColumn("Medicine_name", typeof(string));
DataColumn dc3 = new DataColumn("Medicine_cost", typeof(string));
DataColumn dc4 = new DataColumn("Manufacture_Name", typeof(string));
DataColumn dc5 = new DataColumn("Batch_No", typeof(string));
DataColumn dc6 = new DataColumn("Expiry_Date", typeof(DateTime));
DataColumn dc7 = new DataColumn("Rupees", typeof(int));
DataColumn dc8 = new DataColumn("Total", typeof(int));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);
dt.Columns.Add(dc8);
dt.Rows.Add(msktextdate.Text, txtname.Text, txtdoctorname.Text, txtaddress.Text);
dataGridView1.DataSource = dt;
ds.Tables.Add(dt);
}
private void btnadd_Click(object sender, EventArgs e)
{
createrow();
Form2 frm = new Form2();
frm.Show();
 
 
public DataSet returndata()
{
return ds;
}
 
Form2 code :
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
Form2 frm = new Form2();
CrystalReport1 rpt = new CrystalReport1();
Form1 frm1 = new Form1();
DataSet ds = new DataSet();
ds = frm1.returndata();
rpt.SetDataSource(ds.Tables["table1"]);
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.Refresh();
}
 
 
 
 

Answers (3)