Page 1 of 1

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

Posted: Wed Apr 22, 2009 3:35 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.

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


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

Posted: Wed Apr 22, 2009 6:51 am
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.

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

Posted: Wed Apr 22, 2009 9:53 am
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 ?





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

Posted: Wed Apr 22, 2009 10:57 am
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.

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

Posted: Wed Apr 22, 2009 7:41 pm
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 ?