ADO NET, datasets and reports

  • Thread starter Thread starter Henri
  • Start date Start date
H

Henri

hi,

i'm using the "insertion model" of ADO.NET to see my reports. this model is
the desconnected model of NET.

i have to create a dataset object (visual dataset schema), base my report on
it and after: a form with a crystalreportviewer, configure its property
"reportSource"

this method requires code which fills the dataset of our SQL's data and pass
it to our report with the "setdatasource" method.

i haven't any problem with one table or more tables but when i try filtering
data, it doesn't work

=> i saw the example of crystal report (pdf document) with 2 tables but not
filtered so i've got all the data, and i've tried to filter the data of the
first table in the SQL expresion and with the selectionFormula too. but it
was imposible.

here is the code:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.OleDb

Dim crReportDocument As New CrystalReport1()

Dim DataSet1 As DataSet
Dim adoOleDbConnection As OleDbConnection
Dim adoOleDbDataAdapter As OleDbDataAdapter
Dim adoOleDbDataAdapter2 As OleDbDataAdapter

Dim connectionString As String = ""
connectionString = "Provider=SQLOLEDB;"
connectionString += "Server=DBCONN1;Database=pubs;"
connectionString += "User ID=userid;Password=password"

adoOleDbConnection = New OleDbConnection(connectionString)

Dim sqlString As String = ""
sqlString = "SELECT * FROM authors"
adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, adoOleDbConnection)

sqlString = "SELECT * FROM titleauthor"
adoOleDbDataAdapter2 = New OleDbDataAdapter(sqlString,
adoOleDbConnection)

DataSet1 = New DataSet()

adoOleDbDataAdapter.Fill(DataSet1, "authors")
adoOleDbDataAdapter2.Fill(DataSet1, "titleauthor")

crReportDocument.Database.Tables(0).SetDataSource(DataSet1)


thanks
 
Henri said:
hi,

i'm using the "insertion model" of ADO.NET to see my reports. this model is
the desconnected model of NET.

i have to create a dataset object (visual dataset schema), base my report on
it and after: a form with a crystalreportviewer, configure its property
"reportSource"

this method requires code which fills the dataset of our SQL's data and pass
it to our report with the "setdatasource" method.

i haven't any problem with one table or more tables but when i try filtering
data, it doesn't work

=> i saw the example of crystal report (pdf document) with 2 tables but not
filtered so i've got all the data, and i've tried to filter the data of the
first table in the SQL expresion and with the selectionFormula too. but it
was imposible.

Why it is impossible? What are you trying to achieve?
sqlString = "SELECT * FROM authors WHERE name LIKE ?"
....
adoOleDbDataAdapter.Parameters.Add("@authorName", OleDbType.VarChar).Value =
"tubo"

Should filter authors where name is like tubo*.
 
ok, i'll try it but just a question: to filter the data i can choose between
using the parameters collections or filter data directly in the SQL
expresion, isn't it?

and i'd like to specify that i must work with 2 tables to have something
like: all the orders of the customer number x. i mean i must use a INNER
JOIN sql expresion

thanks for your request
 
Henri said:
ok, i'll try it but just a question: to filter the data i can choose between
using the parameters collections or filter data directly in the SQL
expresion, isn't it?

Right. However, using parameters is better approach because of at least
three reasons:
- security
- no need to format data (decimals, date)
- faster execution on more than one same stataement with different
parameters

and i'd like to specify that i must work with 2 tables to have something
like: all the orders of the customer number x. i mean i must use a INNER
JOIN sql expresion

Doesn't matter.
 
Back
Top