Click here to Skip to main content
13,198,563 members (25,314 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 25 Sep 2008

Get Tables and Fields in Crystal Rport Using Code

, 25 Sep 2008
Rate this:
Please Sign up or sign in to vote.
Get Tables and Fields in Crystal Rport Using Code


Sometimes beginners in development fields struggle with Crystal Reports, so I hope this article will give them some kind of idea of what we can do using VB.NET or C# with Crystal Report.


One of my friends wanted to create a solution where all the features are customized, like reports, forms etc. So he wants to make a solution to add a report dynamically to a system and give a benefit to user, create a selection formula by dynamically.

Using the Code

To start, we all know the .NET Framework is a big library with a collection of lots of things. Today Crystal Reports is one of part in .NET Framework (in earlier years it was not like that,[VB.6.0]). If you are beginner to .NET development hope using this article you can get an idea of how you can access Crystal Reports in your code. First of all you have to imports the following Class Libraries Imports Crystal Imports CrystalDecisions Imports CrystalDecisions.CrystalReports Imports CrystalDecisions.Windows

Dim i As Integer = 0
Dim j As Integer
Dim rptTets As New RPT_Invoice
'Dim rptTets As New CrystalReport -This is a Customized method

For i = 0 To rptTets.Database.Tables.Count - 1


    For j = 0 To rptTets.Database.Tables.Item(i).Fields.Count - 1

        TreeView.Nodes(i).Nodes.Add("[" +
            rptTets.Database.Tables.Item(i).Fields.Item(j).Name + "," +
            rptTets.Database.Tables.Item(i).Fields.Item(j).ValueType.ToString() +



In here I used TreeView to load tables and fields, the first loop gets the all the table and second loop get the fields in side the table in the report.

All the comments are welcome.... Cheers


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


About the Author

Gayan Buddhika
Software Developer (Senior) MyCare
New Zealand New Zealand
Gayan worked as a Senor Software Engineer and a Team Lead in AmSafe Bridport. He has completed his Master Degree in IT and he is a Microsoft Certified Technology Specialist in SharePoint 2010 application development. Gayan has more than 7 years of software development experience with Microsoft technologies including .NET, SQL, SharePoint, IIS, Silverlight, Expression Blend 4 and many more. Currently he is reading for his Postgraduate Diploma in Business Administration at AIS in Auckland, New Zealand.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
kh2tech21-Oct-13 11:45
memberkh2tech21-Oct-13 11:45 
GeneralRe: My vote of 1 Pin
Gayan Buddhika22-Oct-13 10:58
memberGayan Buddhika22-Oct-13 10:58 
GeneralRe: My vote of 1 + question? Pin
kh2tech27-Oct-13 12:35
memberkh2tech27-Oct-13 12:35 
GeneralRe: My vote of 1 + question? Pin
Gayan Buddhika29-Oct-13 11:57
memberGayan Buddhika29-Oct-13 11:57 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 26 Sep 2008
Article Copyright 2008 by Gayan Buddhika
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid