Click here to Skip to main content
6,595,444 members and growing! (18,252 online)
Email Password   helpLost your password?
Languages » VB.NET » HowTo     Beginner License: The Code Project Open License (CPOL)

Get Tables and Fields in Crystal Rport Using Code

By Gayan Buddhika

Get Tables and Fields in Crystal Rport Using Code
VB, .NET (.NET 2.0), Visual Studio, Dev
Posted:25 Sep 2008
Views:4,897
Bookmarked:4 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
2 votes for this article.
Popularity: 0.30 Rating: 1.00 out of 5
2 votes, 100.0%
1

2

3

4

5

Introduction

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.

Background

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

            TreeView.Nodes.Add(rptTets.Database.Tables.Item(i).Name.ToString)

            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() +
                    "]")

            Next

        Next

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

License

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

About the Author

Gayan Buddhika


Member
G.A Pubudu Gayan Buddhika currently working as a Senior Software Engineer in AmSafe Bridport.This year He will complete His Masters Degree. Pubudu has more than 5 year industries experience as a Software Developer and system Designer. He has experience in VB 6.0 VB.NET 2003 AND 2005. also He has experience developing Active X controls.
Occupation: Software Developer (Senior)
Location: Sri Lanka Sri Lanka

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 25 Sep 2008
Editor: Sean Ewington
Copyright 2008 by Gayan Buddhika
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project