How to pass sql parameter query in crystal reports for databinding

Posted by Sathiya_Narayanan under ASP.NET on 3/27/2012 | Points: 10 | Views : 4388 | Status : [Member] | Replies : 1
Hi
'm generating crystal report from database..
Here i have to generate only specific rows...
i have used sql query is SELECT * FROM [TABLENAME] WHERE COLOUMNAME=" ".
Here this works in query builder but not performing in crystal reports, it shoes again entire report.
here is my cs coding

obj.Open();
string sqlquery = "select * from xcd where batch='24-28'";
SqlCommand objcmd = new SqlCommand(sqlquery, obj);
SqlDataAdapter da = new SqlDataAdapter(objcmd);
DataSet ds = new DataSet();
da.Fill(ds);
CrystalReportViewer1.DisplayGroupTree = false;
CrystalReportViewer1.HasCrystalLogo = false;
ReportDocument rptdoc;
rptdoc = new ReportDocument();
rptdoc.Load(Server.MapPath("crystalreport2.rpt"));
rptdoc.SetDatabaseLogon("sxxx", "xxxxx");
rptdoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptdoc;
CrystalReportViewer1.RefreshReport();



have to modify any query or how???

SATHIYANARAYANAN


Responses

Posted by: Rajni.Shekhar on: 3/27/2012 [Member] Bronze | Points: 25

Up
0
Down
create a parameter in your report and pass it to the report in your page using ParameterField

check below link, may be it will give you some idea.
http://p2p.wrox.com/book-professional-crystal-reports-vs-net/17318-how-pass-parameter-crystal-report-using-c.html

Thanks,
Rajni Shekhar

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response