Crystal report in C#

“ open visual studio and select new project from file menu”

“ Select the Language c# and select the window application give the name to your project and select the
path where the project will save ”

“After the opening the project first create the database from server explore”

“Right click on the data connection and select the Create New SQL SERVER Database then create SQL server
database window will open”

“Select the server name or if you are using the local server just give”.” In Log on to the server if you give the username or password in sql then select the sql server authentication or use windows authentication mode   ,write the new database name in textbox you find it down side. ”

“now we going to create the table in the database called info just right click on the table folder you find it inside the server Explorer then select the add new table”

“Give the column name and its data type after this save the table by clicking the save button or CTRL+s”

“After clicking the save button one window will be open called choose name within it give the table name ‘emp’”

“Ok now your table will be created then what? Fill that table by right clicking on the emp table and choose the show table data from emp table in the server explorer”

“Enter some record in the emp table and the click on ‘!’ this”

“now the big work start in your right side open the solution explorer right click on the project  go to add and click the add new item.”

“Add new item window will open and select the crystal report give it name and click add button. after clicking it crystal report gallery will open. ”

“Select blank report and click ok button”

“After it select your form and in toolbox drag the crystalReportViewer in your form not in crystal report and drag one button in your form”

“Your form will look like this”.

“Go to data in menu and select the add new data source now data source configuration wizard will open and select the data base, click next button”

“Now if you have make new connection click the new connection button click continue”

“Give server name or ‘.’ And select the database which is created I select info database  which is created at the begging  and test your connection by clicking in the test connection if all thing is going right click ok button then click next in the data source configuration wizard”

“Give the connection string and again next button click”

“Select the table object called emp and its fields”

“Now go to your crystal report and open field explore right click on the data field and click the database expert”

“Now the window will open, project data >> database >>select your table”

“Open file explore and drag and drop the field in your data base”

“After dragging the field your crystal report looks like that”

“Now I form double click on the button and write the following code for making the connection and crystal report set the report source to the crystal report viewer for making the database connection read previous post.

private void button1_Click(object sender, EventArgs e)


string conn = "Data Source=.;Initial Catalog=info;Integrated Security=True;Pooling=False";

SqlConnection CN =new SqlConnection(conn);

CrystalReport1 crt = new CrystalReport1();

string sql = null;

if (CN.State == ConnectionState.Open)



sql = "select * from emp";

SqlDataAdapter dscmd = new SqlDataAdapter(sql, CN);

infoDataSet ds = new infoDataSet();

dscmd.Fill(ds, "emp");


crystalReportViewer1.ReportSource = crt;



8 thoughts on “Crystal report in C#

  1. Hi, thx for the info. Truly usefull. But, i kinda confuse about ‘the button’… what button? in what form?

    and report depends on how we create query to pull the data, right? Or maybe I probably not quite understand. T_T

  2. comment afficher chauque ligne de la table emp sur une page , cette a dire chaque ligne pour chaque page ???

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.