469,364 Members | 2,398 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

How can I load Crystalreport with StoredProcedure in C#.

Hi friends...

I have one problem...
I am using C#, and CrystalReport9.
In my project I used StoredProcedure with one input parameter.

My Problem:

I would like to load my report.
But It seems lot of errors....

Please help me... "How can I load Crystalreport with Stored Procedure."
If u can give sample code also....

Thanking u....
Jul 23 '07 #1
2 2907
kenobewan
4,871 Expert 4TB
Yes you can use a stored procedure. What are the errors?
Jul 23 '07 #2
luwina
1
Hi,

Load a crystalreportviewer in your form. Put the code at Page_Load().


here's the code:
OdbcCommand com = new OdbcCommand("CALL sp_name(?)", con);
com.CommandType = CommandType.StoredProcedure;

com.Parameters.Add(new OdbcParameter("?param1", OdbcType.Int, 3));
com.Parameters["?periodid"].Direction = ParameterDirection.Input;
com.Parameters["?periodid"].Value = 41;

OdbcDataAdapter da = new OdbcDataAdapter();
DataSet ds = new DataSet();

da.SelectCommand = com;
da.Fill(ds, "tablename");

CrystalDecisions.CrystalReports.Engine.ReportDocum ent myReportDocument;
myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
myReportDocument.Load(@"C:\ASP.NET\Reports\ReportN ame.rpt");
myReportDocument.SetDataSource(ds);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();


Hope it helps :)

Luwina
Jul 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by s-galit | last post: by
3 posts views Thread by redneon | last post: by
2 posts views Thread by Don Wash | last post: by
3 posts views Thread by Jason Huang | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.