Professional Documents
Culture Documents
Step 3:-
Now to select database, (My Database is stored in SQL Server 2000)
Right Click on Database Fields in Field Explorer.
Select Add/Remove Database -> OLEDB(ADO) ->Make New Connection -> Microsoft
OLE DB Provider for SQL Server (As I am using SQL Server 2000). Click on Next and
give your connection Information, Click on Next and then Click on Finish.
Now you can add your table/s, view/s which you required for the Report. The window
looks like this.
Step 4: -
Now in your Field Explorer you can see your chosen Table/View. Drag the Fields you
want to show in the report in Details Section. The screen will appear as follows.
The fields in Details section are Field Objects and the fields in Page Header, Report
Header are Text Objects.
Step 5:-
Now to show this report, Take a form & add a CrystalReportViewer to it.(Just drag
CrystalReportViewer from Tool box on the form).
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
privatevoid SetLogonInfo()
{
try
{
LogInfo.ConnectionInfo.ServerName=”SerVerName”;
LogInfo.ConnectionInfo.UserID=”sa”;
LogInfo.ConnectionInfo.Password=”ok”
LogInfo.ConnectionInfo.DatabaseName=”CrystalSample”;
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
Now we need to create object of the report. There are various ways to showreport.
a) Create one object of Report Documentthat can beuse to every report which are
going to be shown on that CrystalreportViewer canbe created as
ReportDocumentO_Report=new ReportDocument();
We can use this object to every report and need togive pathwhile
loading the report.as
O_Report.Load(@"E:\CrytstalSample\rptShowList.rpt");
Step 6:-
Now I want to show AddressList of the userswhose number is
greater than 15. For that I will fill DataTable with theserecords
and then attach it to the report.
Step 7:-
Now set the above filled DataTable as ReportsdataSource.
O_showlist.Database.Tables[0].SetDataSource(DT);
Step 8: -
Set the report as crystal report viewer reportsource tobind
report to viewer.
CryStalReportViewer1.ReportSource = O_Report1111;
CryStalReportViewer1.Zoom(1);
e.g. In the above ReportUser Number and user Streetasddress are the
field objects. We can change thereproperties as
FieldObject fUserNumber
=FieldObject)o_showlist.Sections3.ReportObjects["Field1"];
fFullName1.ApplyFont(new Font(Arial,8.25F));
Formula Fields:-
Here I will just give sample of how to use formulafield. It’s out
ofscope to give whole FormulaField Description.
if({Vw_AddressList.Gender})='M' then
'Male'
else
'Female'
a) AddingMerge Module:-
• Right Clickon Setup project ->Add ->Merge Module
• Select‘Crystal_regwiz2003.msm’, Crystal_Managed2003.msm,
Crystal_Database_Access2003_enu.msm,Crystal_Managed2003.msm
• Click on Open.
b) Nowimportant thing is that When you run this Set up on another sytem it will
giveyou error of “Keycode32.Dll”
The error isdue to not giving Registration key to Merge Module File‘
‘Crystal_regwiz2003.msm’ Todo that Right Click on
‘Crystal_regwiz2003.msm’ and selectProperties.
In properties select ‘(MergeModuleProperties)’->
Enter your key at‘License Key‘.
Now the License key can beyour Crystal Report product key or you can
get it from,
Help(Menu of dot net) ->About Microsoft Development Environment.
There you will see thestring “Crystal Reports for Visual Studio .NET
AAP50-GS00000-U7000RN“(can bedifferent for different versions).Your
key is'AAP50-GS00000-U7000RN'.