Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
AnswerRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
jschell3-Sep-11 10:39
jschell3-Sep-11 10:39 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
bigz_10004-Sep-11 0:11
bigz_10004-Sep-11 0:11 
GeneralRe: Email Sender :the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Pin
Michael J. Eber8-Sep-11 7:47
Michael J. Eber8-Sep-11 7:47 
QuestionC#4.0 How Connect Crystal Report [modified] Pin
Ken H1232-Sep-11 21:10
Ken H1232-Sep-11 21:10 
AnswerRe: C#4.0 How Connect Crystal Report Pin
Abhinav S2-Sep-11 21:28
Abhinav S2-Sep-11 21:28 
AnswerRe: C#4.0 How Connect Crystal Report Pin
Vijjuuu.3-Sep-11 1:53
Vijjuuu.3-Sep-11 1:53 
GeneralRe: C#4.0 How Connect Crystal Report Pin
Ken H1234-Sep-11 20:47
Ken H1234-Sep-11 20:47 
AnswerRe: C#4.0 How Connect Crystal Report Pin
palanidothis4-Sep-11 6:50
palanidothis4-Sep-11 6:50 
C# Crystal Reports step by step
A step by step tutorial for beginners who is creating their Crystal Reports for the first time in C#.
All C# Crystal Reports Tutorial in this website is based on the following database - crystaldb. So before you begin this section , please take a look at the database structure of crystaldb - Click Here C# crystaldb
Here we are going to create a new Crystal Reports in C# from Product table in the above mentioned database crystalDB. The Product Table has three fields (Product_id,Product_name,Product_price) and we are showing the whole data from Product table to the C# - Crystal Reports project.
Open Visual Studio .NET and select a new CSharp Windows project.

Now you will get the default Form1.cs.
From the main menu in Visual Studio C# project select PROJECT-->Add New Item . Then Add New Item dialogue will appear and select Crystal Reports from the dialogue box.

Select Report type from Crystal Reports gallery.

Accept the default settings and click OK.
Next step is to select the appropriate connection to your database (here crstaldb). Here we are going to select OLEDB Connection for SQL Server to connect Crystal Reports in C#.
Select OLE DB (ADO) from Create New Connection .

Select Microsoft OLE DB Provider for SQL Server .

The next screen is the SQL Server authentication screen for connecting to the database - crystalDB. Select your Sql Server name , enter userid , password and select your Database Name .

Click next , Then the screen shows OLE DB Property values , leave it as it is , and then click finish button.

After you click the finish button , the next window you will get your Server name under OLEDB Connection, from there selected database name (Crystaldb) and click the tables , then you can see all your tables from your database.
From the tables list double click the Product table then you can see the Product table will come in the right side list.

Click Next Button
Select all fields from Product table to the right side list .

Click Finish Button. Then you can see the Crystal Reports designer window in your C# project. In the Crystal Reports designer window you can see the selected fields from Product table. You can arrange the field Objects and design of the screen according your requirements. After that your screen is look like the following picture.

Now the designing part is over and the next step is to call the Crystal Reports in your C# application and view it through Crystal Reports Viewer control in C#.
Select the default form (Form1.cs) you created in C# and drag a button and a CrystalReportViewer control to your form .

After you drag the CrystalReportViewer to your form , it will look like the following picture.

You have to include CrystalDecisions.CrystalReports.Engine in your C# Source Code.
using CrystalDecisions.CrystalReports.Engine;
Copy and paste the following source code and run your C# project
Download Source Code
Print Source Code




using System;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
}
}
}

NOTES:
cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");

The Crystal Reports file path in your C# project file location, there you can see CrystalReport1.rpt . So give the full path name of Crystal Reports file like c:\projects\crystalreports\CrystalReport1.rpt

When you run the source code you will get the report like the following picture.



When you click the button, the application will ask the username and password. Later in this tutorial you can find how to avoid asking username and password - C# Dynamic logon parameters in Crystal Reports
GeneralRe: C#4.0 How Connect Crystal Report Pin
Ken H1234-Sep-11 20:45
Ken H1234-Sep-11 20:45 
GeneralRe: C#4.0 How Connect Crystal Report Pin
Ken H1234-Sep-11 20:48
Ken H1234-Sep-11 20:48 
QuestionLock DLL in C# Pin
jojoba20112-Sep-11 20:53
jojoba20112-Sep-11 20:53 
AnswerRe: Lock DLL in C# Pin
Abhinav S2-Sep-11 21:25
Abhinav S2-Sep-11 21:25 
AnswerRe: Lock DLL in C# Pin
harold aptroot3-Sep-11 1:32
harold aptroot3-Sep-11 1:32 
AnswerRe: Lock DLL in C# PinPopular
jschell3-Sep-11 10:43
jschell3-Sep-11 10:43 
GeneralRe: Lock DLL in C# Pin
Eddy Vluggen3-Sep-11 13:04
professionalEddy Vluggen3-Sep-11 13:04 
QuestionEmailSender : A socket operation was attempted to an unreachable network Pin
bigz_10002-Sep-11 19:53
bigz_10002-Sep-11 19:53 
AnswerRe: EmailSender : A socket operation was attempted to an unreachable network Pin
Mehdi Gholam2-Sep-11 20:03
Mehdi Gholam2-Sep-11 20:03 
Question[SOLVED] "Negative" Rectangle (ControlPaint.DrawReversibleFrame) To "Positive" Pin
Matt U.2-Sep-11 13:39
Matt U.2-Sep-11 13:39 
QuestionC# code for windows Pin
dcof2-Sep-11 6:45
dcof2-Sep-11 6:45 
AnswerRe: C# code for windows Pin
Abhinav S2-Sep-11 6:59
Abhinav S2-Sep-11 6:59 
QuestionRe: C# code for windows Pin
dcof2-Sep-11 18:13
dcof2-Sep-11 18:13 
AnswerMessage Removed Pin
2-Sep-11 7:05
professionalN_tro_P2-Sep-11 7:05 
GeneralRe: C# code for windows Pin
Luc Pattyn2-Sep-11 7:15
sitebuilderLuc Pattyn2-Sep-11 7:15 
GeneralRe: C# code for windows Pin
Abhinav S2-Sep-11 8:01
Abhinav S2-Sep-11 8:01 
QuestionRe: C# code for windows Pin
dcof2-Sep-11 8:34
dcof2-Sep-11 8:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.