StiDataBand.DataSourceName

Stimulsoft Reports.NET discussion
Post Reply
Sandy Pham
Posts: 62
Joined: Mon Dec 11, 2006 1:43 pm
Location: U.S.A.

StiDataBand.DataSourceName

Post by Sandy Pham »

I do not understand how StiDataBand.DataSourceName works when using DataSets. I have a DataSet with 5 tables that have DataRelations set up. I would like to be able to add data to the StiDataBand from my main table and also the 4 tables that are related to it.

I tried setting StiDataBand.DataSourceName to the name of my DataSet (dataBand.DataSourceName = ds.DataSetName). That did not work.

Then, I tried setting it to the name of one of my tables in the dataset (dataBand.DataSourceName = ds.Tables[0].TableName). That worked. However, I seem to be able to add data to the band from any table in the dataset. So, why do you have to set it to the name of a table?

Also, when would I need to set the DataRelationName property?

Thanks,

Sandy
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

StiDataBand.DataSourceName

Post by Vital »

That correct. One Databand = one table. For example if table have 10 rows then databand will be output to result page 10 times.
If you need output two tables palce two databands. If you need output master-detail report then you need place two databands -
master band and detail band. Set DataSourceName of each databand to equal tables. After then set property MasterComponent
of DataBand2 to DataBand1 and set property RelationName of DataBand2 to your relation name.

Please visit following page: http://www.stimulsoft.com/LiveDemos.aspx

For output fields on report you need place textbox on any databand (or directly on page). After then in property Text write:

{NameOfTable.NameOfField}

If you need generate report from code please see sample project - PrintGrid and PrintTable.

Let me know if you need any help.

Thank you.
Sandy Pham
Posts: 62
Joined: Mon Dec 11, 2006 1:43 pm
Location: U.S.A.

StiDataBand.DataSourceName

Post by Sandy Pham »

Thanks Vital.

I was able to get what I wanted by using DataRelations in my DataSet. However, my users are not technical and will not understand the concept of "joins" and SQL. The report designer displays my tables A, B, C. Then, because I have DataRelations set up it also displays tables B & C under table A. In order for the join to happen, the users will have to select fields from the tables listed underneath table A. Is there a way to just display table A and its DataRelations. In other words, I just want to show the A tree branch with B and C as child nodes, but I don't want tables B and C to appear as separate tree branches.

Thanks,

Sandy
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

StiDataBand.DataSourceName

Post by Vital »

You can add restrictions to report dictionary. For example, to prevent show datasource "Categories" you can use
following code:

Code: Select all

report.Dictionary.Restrictions.Add("Categories", StiDataType.DataSource, StiRestrictionTypes.DenyShow);
Thank you.
Post Reply