Click here to Skip to main content
15,868,217 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
Hi,

in winform (c#), I want to use CrystalReport and reportview but CrystalReport use storedprecedure, some parameters come from in form elements some form code behind.


Best regards
Posted

Hello ,

you can find many examples in google .


How to Create a Basic Crystal Report using Windows Forms and C#

csharp-crystal-reports-stepbystep

and for crystal report with parameter try this

crystal-reports-in-winforms-parameter

thanks
 
Share this answer
 
Thanks but I think that there are no information about how stored procedure takes parameters for CrystalReport.
 
Share this answer
 
I have used stored procedure that takes parameter for Crystal report but i have used it in WPF

by the way the procedure wii be same in Winfrom also.here goes the procedure i have followed

1) new .rpt file and open Field Explorer then Database Expert there you select your database under that the storedprocedure(input parameters) you want to bind and set storedprocedure parameter as null and click okay.

2)Here am using the Crystalreportviewer in Report.xaml as show below

XML
<Window x:Class="App.Report"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
        Title="Report" Height="969" Width="944" Loaded="Window_Loaded">
    <Grid>
        <my:CrystalReportsViewer Name="crystalreportviewer" IsManipulationEnabled="True"></my:CrystalReportsViewer>
    </Grid>
</Window>


used the below method for
C#
private void GenerateReport(DateTime Fromdate, DateTime Todate, Int64 mobNo, string rptName)
        {
            Report rpt = new Report();
            rpt.Show();
            ReportDocument report = new ReportDocument();
            report.Load("" + GetCurrentPath()[0] + "Reports\\" + rptName + "");
            report.SetDatabaseLogon("sa", "password");//if your are using sqlAuthentication
            report.SetParameterValue("@Fromdate", Fromdate);
            report.SetParameterValue("@Todate", Todate);    
            rpt.crystalreportviewer.ViewerCore.ReportSource = report;
}


My required stored procedure contains two parameters.Hope this would be helpful.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900