Page 1 of 1

How to passing run-time created dataset to report ?

Posted: Mon Apr 27, 2009 8:12 am
by stvhui
Hello to you,

I'm newbie in .net world, also newbie using stimulsoft report.
I'm using VB.NET 2005, StimulReport 2008.2, MS-ACCESS 2000 database

How to passing data to report ?

The scenario is :
I hv database named "ABC"
contains TBLCUSTOMER (CustomerID, CustomerName, Address)

I hv a Form, named "Form1"
contains button "btnPreview"

I want to do is :
When "btnPreview" clicked, I want to passing the data table (dt) for customername like 'J%' to preview

I try put some code to btnPreview as shown :
Public dt As DataTable
Public da As OleDb.OleDbDataAdapter

da = New OleDb.OleDbDataAdapter("select * from tblCustomer where customerid like 'J%'", pCnn2AppDB)

dt = New DataTable()
da.Fill(dt)

Dim rpt As New Stimulsoft.Report.StiReport
rpt.Load("c:\test.mrt")

rpt.RegData("dt", dt)


rpt.Show()

from above code, the report will shown all the data, but I just want to show for CustomerName like 'J%'

Please show me the code & guide me step by step.

How to passing run-time created dataset to report ?

Posted: Tue Apr 28, 2009 2:00 am
by Stephan1
Hi Stvhui,

i think you see the right Data in your report because you allready set the SQL Statement in your Datatable of the report.

What you need is to pass your new statement to the existing report and then open it.

This is what i do.


Dim stireport1 As New Stimulsoft.Report.StiReport
stireport1.Load(filename)

Dim sqlDB As Stimulsoft.Report.Dictionary.StiSqlDatabase
sqlDB = stireport1.Dictionary.Databases("NameofConn")

If Not IsDBNull(sqlDB) Then
sqlDB.ConnectionString = constr
End If

stireport1.RegData(Kddataset.Tables("TmpReport1"))
stireport1.Dictionary.Synchronize()
stireport1.Show()


You need to bind your new Conn to the Report. Where "NameofConn" is the Name of your Database Connection in your report.

To Check if your report has the right SQL Statement "("select * from tblCustomer where customerid like 'J%") You can call

the method: rpt.design instead of the rpt.show.

Hope this helps


stephan

How to passing run-time created dataset to report ?

Posted: Tue Apr 28, 2009 4:02 am
by stvhui
Hi Stephan,

Could you figure-out completely ?

because from yr code, I don't see when you create dataset/datatable at run-time.

Then how passing it to report (test.mrt).

Please using my scenario....

Thanks,
Steven

How to passing run-time created dataset to report ?

Posted: Thu Apr 30, 2009 1:49 am
by Jan
Hello,

Report engine use data which you provide to it. If you recieve full set of your data table then something wrong with query.

Thank you.