[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to Create a Crystal Reports from sql query string in vb.net

Posted on 2009-05-14
7
Medium Priority
?
1,021 Views
Last Modified: 2012-05-07
I tried to create a crystal report according to the user choice in a vb form. For that i like to pass a dynamically generated query
to crystal report. But when im assigning the "SetDataSource" property of CR by the following coding its giving the error
 
"Object reference not set to an instance of an object ." ....

i used the following coding...




help me...

Thanks in advance
Public Class Form1
    Dim rpt As CrystalReport1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cnn As OleDbConnection
 
     
        cnn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ELA\Current\Tailor_Software\TailorDb.mdb")
        cnn.Open()
       
        Dim da As New OleDbDataAdapter("select * from User_Master", cnn)
        Dim ds As New DataSet
        da.Fill(ds, "User_Master")
 
         rpt.SetDataSource(ds.Tables(1))    'I am having the error at here
 
        CrystalReportViewer1.ReportSource = rpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

Open in new window

0
Comment
Question by:kamikazis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 24383213
you normally provide the full dataset to a report, not just a table.

also, the table collections is 0-based. so if you want to access the first table, you need to provide the index 0 (ds.tables(0))

Finally, have a look at http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx
0
 

Author Comment

by:kamikazis
ID: 24394107
hi emoreau, ur page is very useful... Now i overcame this error...Now its executing correctly...But i want to display a crystal report as user desire by giving his choices in a vb form....I want to learn about grouping also..i tried gouping but nothing comes in CR...  Plz help me  Eric....
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24394168
>>But i want to display a crystal report as user desire by giving his choices in a vb form

I have explained that in my article. See the "Passing a value to a parameter of the report" section.

For grouping, have a look at http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24395005
What user choices?  What will the choices do?

mlmcc
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 25447831
I think I put kamikazis on the right track
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question