Vb.Net With Crystal Report


G

Guest

Hi ,

I create a crystal report link with Nortwind database with products
table and import into a .net project

But I pass the query "SELECT * FROM Products Where ProductID = 1" to
the dataset and bind the report.setdatasource=dataset but it still show all
the product details in the report.

I means the report did not show the data base on the query I pass ...
any idea on that ? Attachment is the code I use on the form.

Dim rpt As New Product 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand
Dim myDA As New SqlDataAdapter
Dim myDS As New Dataset1 'The DataSet you created.


Dim strQuery As String

MyConnection = New SqlConnection("Data
Source=(local);uid=sa;pwd=;Database=Northwind;")

MyCommand.Connection = MyConnection
MyCommand.CommandText = "SELECT * FROM Products Where ProductID = 1"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand

myDA.Fill(myDS)
rpt.SetDataSource(myDS)

rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top