Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Video Content Creator
pramukag
Updated:
Sunday at 6:10 AM
Ad icon
QA Engineer Intern
pramukag
Updated:
Sunday at 6:07 AM
Ad icon
Sell your Land, House on idamata.lk for FREE
sajith.xp.pk
Updated:
Thursday at 9:03 AM
Handmade Character Soft Toys
anil1961
Updated:
Jun 23, 2026
Bodim.lk out now !
Manoj Suranga Bandara
Updated:
Jun 21, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
C# project ekakata, crystal reports
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="amila.ela" data-source="post: 7926013" data-attributes="member: 274557"><p><span style="color: DarkOrange"><span style="font-size: 18px"><img src="http://www.codeproject.com/KB/cs/CreatingCrystalReports/CreatingCrystalReports.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"><img src="http://www.codeproject.com/KB/cs/CreatingCrystalReports/2.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">Create a Dataset</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">First you should create a Dataset to get data from the DB. By clicking the “Add New Item” in the “Project” menu, you can add a Dataset. A picture of an added Dataset looks like the following window and you can add elements to the Dataset by dragging and dropping elements from the toolbox. This Dataset is used to fill the data, which it gets from the DB by using a query. Because of that, the names of the elements in this Dataset should be equal to the names of the elements in the DB. For an example, this Dataset can fill using the following query.</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">String connString = @"Provider=Microsoft.Jet.OLEDB.4.0;_</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"> Data Source=..\\..\\myDB.mdb;User ID=Admin;Password=";</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">OleDbConnection conn = new OleDbConnection(connString);</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">conn.Open();</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">string query = "SELECT studentID, firstName, lastName, birthDate, _</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"> address, contactNo FROM studentInfo";</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">OleDbDataAdapter oleDA = new OleDbDataAdapter(query,conn);</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">The next window looks like the following and you have to select your created Dataset under “Project Data”, and click “Insert Table”, then click next.</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"><img src="http://www.codeproject.com/KB/cs/CreatingCrystalReports/3.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">Then you have to add the field, which you want to display in the report through the following window and click next.</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"><img src="http://www.codeproject.com/KB/cs/CreatingCrystalReports/4.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">You can also go to other tabs of this window and select/deselect your choices. Use the last tab “Style” to select the format of the report. You can also type a Report Title here and click finish</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"><img src="http://www.codeproject.com/KB/cs/CreatingCrystalReports/5.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">Set the Created Report to Display in the Form</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">Then you have to set a “crystalReportViewer” in your form to load the report that you created earlier. Moreover, you need to set the report source of this “crystalReportViewer” component, which falls in the properties panel or you can set the report source by using the code like the following:</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// code to get data from the DB</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">DBConnection DBConn = new DBConnection();</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB();</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// use the created Dataset to fill it with data got</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// from the DB by using the DataAdapter</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">DataSet dataReport = new DataSet();</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">myDataAdapter.Fill(dataReport,"myPersonalInfoTable");</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// create a new report from the created CrystalReport</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">myDataReport myDataReport = new myDataReport();</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// set the data source of the report</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">myDataReport.SetDataSource(dataReport);</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// set the report source of the created “crystalReportViewer”</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">// component to the created report</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px">crystalReportViewer1.ReportSource = myDataReport;</span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p><span style="color: DarkOrange"><span style="font-size: 18px"></span></span></p><p></p><p></p><p><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /><img src="/styles/default/xenforo/smilies/default/P.gif" class="smilie" loading="lazy" alt=":P" title=":P :P" data-shortname=":P" /></p></blockquote><p></p>
[QUOTE="amila.ela, post: 7926013, member: 274557"] [COLOR="DarkOrange"][SIZE="5"][IMG]http://www.codeproject.com/KB/cs/CreatingCrystalReports/CreatingCrystalReports.jpg[/IMG] [IMG]http://www.codeproject.com/KB/cs/CreatingCrystalReports/2.jpg[/IMG] Create a Dataset First you should create a Dataset to get data from the DB. By clicking the “Add New Item” in the “Project” menu, you can add a Dataset. A picture of an added Dataset looks like the following window and you can add elements to the Dataset by dragging and dropping elements from the toolbox. This Dataset is used to fill the data, which it gets from the DB by using a query. Because of that, the names of the elements in this Dataset should be equal to the names of the elements in the DB. For an example, this Dataset can fill using the following query. String connString = @"Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=..\\..\\myDB.mdb;User ID=Admin;Password="; OleDbConnection conn = new OleDbConnection(connString); conn.Open(); string query = "SELECT studentID, firstName, lastName, birthDate, _ address, contactNo FROM studentInfo"; OleDbDataAdapter oleDA = new OleDbDataAdapter(query,conn); The next window looks like the following and you have to select your created Dataset under “Project Data”, and click “Insert Table”, then click next. [IMG]http://www.codeproject.com/KB/cs/CreatingCrystalReports/3.jpg[/IMG] Then you have to add the field, which you want to display in the report through the following window and click next. [IMG]http://www.codeproject.com/KB/cs/CreatingCrystalReports/4.jpg[/IMG] You can also go to other tabs of this window and select/deselect your choices. Use the last tab “Style” to select the format of the report. You can also type a Report Title here and click finish [IMG]http://www.codeproject.com/KB/cs/CreatingCrystalReports/5.jpg[/IMG] Set the Created Report to Display in the Form Then you have to set a “crystalReportViewer” in your form to load the report that you created earlier. Moreover, you need to set the report source of this “crystalReportViewer” component, which falls in the properties panel or you can set the report source by using the code like the following: // code to get data from the DB DBConnection DBConn = new DBConnection(); OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB(); // use the created Dataset to fill it with data got // from the DB by using the DataAdapter DataSet dataReport = new DataSet(); myDataAdapter.Fill(dataReport,"myPersonalInfoTable"); // create a new report from the created CrystalReport myDataReport myDataReport = new myDataReport(); // set the data source of the report myDataReport.SetDataSource(dataReport); // set the report source of the created “crystalReportViewer” // component to the created report crystalReportViewer1.ReportSource = myDataReport; [/SIZE][/COLOR] :P:P:P:P [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom