1
votes

I am new to work with vb.net and crystal report I searched many links while failed to populate or load SQL query result on crystal report?

here is the code to load query result on grid-view

 Dim cc As SqlConnection = New SqlConnection(" Server=(localdb)\Projects;Database=question;Uid=sa;Pwd=12345;")
        Dim cmd As SqlCommand = New SqlCommand("SELECT  * FROM tencmpC1 where qnumber in 1,2,3 ", cc)
             Dim adp, As New SqlDataAdapter(cmd)
        cmd.Connection.Open()Dim ds As DataTable = New DataTable
           adp.Fill(ds)
        grid.ItemsSource = ds.DefaultView
        cmd.Connection.Dispose()

But what i did with grid-view same that i want with crystal report ?

Dim cmd As SqlCommand = New SqlCommand("SELECT * FROM tencmpC1 where qnumber in 1,2,3 ", cc)

may be number changed every time 1,2,3 or 4,85,9 or 54,96,400 .

here I only need guidance on loading SQL query result on crystal report?

thanks in advance.

sorry if its hard to understand I try my level best to express my self what I want.

enter image description here

1

1 Answers

0
votes

You have two ways to do this :

  1. Crystal Report Parameters : User can manually pass the parameters to the crystal report at runtime. Using this Parameters, you can pass the desired values to the Crystal Reports. In your example, to SQL Query.

  2. Create a query which accepts data as parameter. And while loading the Crystal Report, Fill data Adapter with that query which will ultimately fill the Crystal Report according to the query.