create report with c# code

Stimulsoft Reports.WEB discussion
lilinikco
Posts: 1
Joined: Sat Mar 26, 2011 11:29 pm

create report with c# code

Post by lilinikco »

hi all.
I need to select some columns and then create sample reports with this columns via code not via designer.pleas guide me how to create report with code?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

create report with c# code

Post by Alex K. »

Hello,

Please see the sample project in attachment.

Thank you.
Attachments
899.DynamicCreateReport.zip
(15.46 KiB) Downloaded 1753 times
Jeniffer
Posts: 8
Joined: Mon Apr 04, 2011 8:32 am
Location: malaysia

create report with c# code

Post by Jeniffer »

Hello
we check that sample,but we would like to use it in a web page and bind the databind to a sqlsource instead of binding to a xml file that you use in this sample,could you help us to chang the codes for databinding part?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

create report with c# code

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DATA\NWIND.MDB;Persist Security Info=False";
DataTable dt = new DataTable("Categories");
using (OleDbConnection conn = new OleDbConnection(connString))
{
    OleDbCommand cmd = new OleDbCommand("SELECT * FROM Categories", conn);
    OleDbDataAdapter da = new OleDbDataAdapter(cmd);
    da.Fill(dt);
}
report.RegData(dt);
report.Dictionary.Synchronize();
instead:

Code: Select all

DataSet ds = new DataSet("Demo");
ds.ReadXmlSchema("e:\\Demo.xsd");
ds.ReadXml("e:\\Demo.xml");
DataTable dt = new DataTable("Categories");
dt = ds.Tables["Categories"];
Thank you.
Jeniffer
Posts: 8
Joined: Mon Apr 04, 2011 8:32 am
Location: malaysia

create report with c# code

Post by Jeniffer »

Hi Aleksey

I really appreciate your concern. Your code works great on Winforms but it have some problems on Webforms.It bind the data to the connection,but it dosen't show anything.
could you check it yourself on webform and tell me what's my mistake?

Thank you very much for your help.
Jeniffer
Posts: 8
Joined: Mon Apr 04, 2011 8:32 am
Location: malaysia

create report with c# code

Post by Jeniffer »

Maybe i must do some changes in webforms.Could you help me?

sincerely yours

Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

create report with c# code

Post by Alex K. »

Hello,

If you want to display data in the WebDesigner in prewiew, you need to implement the GetPreviewDataSet method for a designer in your code.

Thank you.
Jeniffer
Posts: 8
Joined: Mon Apr 04, 2011 8:32 am
Location: malaysia

create report with c# code

Post by Jeniffer »

Hi Aleksey
You mean i must create the report,bind it to the datasouce and so on ,in GetPreviewDataSet event of StiWebDesigner?

sincerely yours
Jeniffer
Posts: 8
Joined: Mon Apr 04, 2011 8:32 am
Location: malaysia

create report with c# code

Post by Jeniffer »

Can you be a bit more precise and tell the changes in codes with presise details in that method?
I appreciate it very much!

sincerely yours
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

create report with c# code

Post by Alex K. »

Hello,

Sorry for the delay with response. We need some additional time to prepare the sample project for you.

Thank you.
Post Reply