inside button1_click event in C# windows application. But In this code I get an error
that "Invalid path of crystal report".
private void button1_Click(object sender, EventArgs e)
{
string str = "select s_first,s_last,s_dob,c_sem,c_year from personaltbl,coursetbl where personaltbl.r_id = coursetbl.r_id and coursetbl.c_name='MCA'";
string str = "select s_first,s_last,s_dob,c_sem,c_year from personaltbl,coursetbl where personaltbl.r_id = coursetbl.r_id and coursetbl.c_name='MCA'";
scmd.CommandText = str;
scmd.Connection = scon;
if (scon.State == ConnectionState.Closed)
scon.Open();
sdap = new SqlDataAdapter(scmd);
sdap.Fill(ds, "personal");
ReportDocument rd = new ReportDocument();
rd.SetDataSource(ds.Tables["personal"]);
rd.Load(@"~/First_Report.rpt");//I also used @"c:\project\project_first\first_Report.rpt"
rd.SetDataSource(ds.Tables["personal"]);
crystalReportViewer1.ReportSource = rd;
crystalReportViewer1.RefreshReport();
if (scon.State == ConnectionState.Open)
scon.Close();
}
catch (Exception ex)
{
MessageBox.Show(" exce :" + ex.Message );
}
}
Please tail me the simple code to display report using sql query.
}
Please tail me the simple code to display report using sql query.

Dinesh AmbaliyaPosted Aug 6, 2012, 8:56 AM
But I think you do not have to set data source to reportdocument before load() method.
kishor chourePosted Aug 2, 2012, 11:24 AM
For that I also used Application.startpath+"\First_report.rpt" same error occured .
Even without load() function program gives same error i.e. "Invalid file path"
Dinesh AmbaliyaPosted Aug 1, 2012, 8:16 AM
rd.Load(Server.MapPath(" ~/First_Report.rpt "));