How to passing data table to report ? customername like 'J%'

Stimulsoft Reports.NET discussion
Post Reply
stvhui
Posts: 51
Joined: Wed Apr 22, 2009 3:12 am

How to passing data table to report ? customername like 'J%'

Post 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.

or maybe I'm wrong in creating TEST.MRT ???
When creating TEST.MRT, I create Connection, named dt, also creating datasource named it as dt

NOTE : Actually I want attach TEST.MRT, but I don't how to attach it witihin this forum.


regards,
Steven
email : stvhui@yahoo.com

Attachments
172.test.mrt
(7.68 KiB) Downloaded 494 times
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

How to passing data table to report ? customername like 'J%'

Post by Ivan »

Hello,
stvhui wrote:How to passing data to report ? The scenario is :
...
Dim rpt As New Stimulsoft.Report.StiReport
rpt.Load("c:\test.mrt")
rpt.RegData("dt", dt)
rpt.Show()
In this case you can use 'Data from DataSets, DataTables' Datasource (you got this answer also in another topic).
stvhui wrote: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.
Please check "SimpleProject" example in attachment. In this example you can send CustomerName to report via Variable.

Thank you.
Attachments
173.SimpleProject.zip
(296.96 KiB) Downloaded 1082 times
stvhui
Posts: 51
Joined: Wed Apr 22, 2009 3:12 am

How to passing data table to report ? customername like 'J%'

Post by stvhui »

Hello Ivan,

Thanks for reply, but I dont understand yr attached code.

Could you tell me, how I can passing run-time query to the report template ?




Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

How to passing data table to report ? customername like 'J%'

Post by Ivan »

Hello,
stvhui wrote:Thanks for reply, but I dont understand yr attached code.
Could you tell me, how I can passing run-time query to the report template ?
In "SimpleProject" example, CustomerName is passed to the report's variable, and then passed to the DataBand's filter.

If you want passing run-time query to the report template, please use next code, for example:

Code: Select all

            (report.Dictionary.DataSources["dt"] as StiOleDbSource).SqlCommand = "select * from tblcustomer where CUSTOMERID=1";
            report.Compile();
            report.Render(true);
            report.Show();
Thank you.
stvhui
Posts: 51
Joined: Wed Apr 22, 2009 3:12 am

How to passing data table to report ? customername like 'J%'

Post by stvhui »

Hi,

My friend told me add some code at the end of my previous posted code as :

rpt.Dictionary.Synchronize()
rpt.Dictionary.DataSources(0).Name = "dt"
rpt.Dictionary.DataSources(0).Alias = "dt"

rpt.Show()

But It's not work, why ?

I don't hv any help about dictionary ?

Post Reply