472,102 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

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 2968
4,871 Expert 4TB
Yes you can use a stored procedure. What are the errors?
Jul 23 '07 #2

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");
CrystalReportViewer1.ReportSource = myReportDocument;

Hope it helps :)

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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.