Rename DataSource Items

Stimulsoft Reports.NET discussion
saidin
Posts: 8
Joined: Thu May 28, 2009 10:28 pm

Rename DataSource Items

Post by saidin »

Hi
Suppose that we have some tables in database and one of them is Table1 and we want to send table1's data to Stimulsoft report
when I do that in dictionary segment I can see DataSource >>Table1 and the columns of Table1(Col1,Col2) but I want to Rename The Table and column Titles in dictionary segment for example instead of Table1 see CustomerTable and instead of Col1 see CustCol1
thanks:grinder:
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rename DataSource Items

Post by Edward »

Hi,

There is an Alias property in the DataSource and Columns as well. Just click in the 'Use Aliases' check box in the Dictionary panel in the designer and you will see aliases instead of the real names.

Thank you.
saidin
Posts: 8
Joined: Thu May 28, 2009 10:28 pm

Rename DataSource Items

Post by saidin »

Hi Edward
No! No!:brick:
I mean that programmer(by source code) change the main names for exp column1 to colName that when user opens a report designer see the colName instead of column1
thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Rename DataSource Items

Post by Jan »

Hello,

You can change Name property of datasource and datacolumn. For example:

NameInSource: Table1
Name: CustomerTable

Thank you.
saidin
Posts: 8
Joined: Thu May 28, 2009 10:28 pm

Rename DataSource Items

Post by saidin »

Hi Jan

My question is how we can do that? but you said you can do
please say how rename items by code(help , code or sample)

thanks
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rename DataSource Items

Post by Edward »

Hi.

Here you are:

Code: Select all

report.Dictionary.DataSources["MyDataSourceName"].Alias = "NewAliasforDataSourceName";
report.Dictionary.DataSources["MyDataSourceName"].Columns["MyDataColumnName"].Alias = "MyNewAliasForColumn";
Thank you.
saidin
Posts: 8
Joined: Thu May 28, 2009 10:28 pm

Rename DataSource Items

Post by saidin »

Hi Edward
I cant use the code
there is one DataSet:DsGlobal
there is one Table:table1
there is some columns of Table1

the following code has error: Object reference not set to an instance of an object.

Report.RegData(DsGlobal)
Report.Dictionary.DataSources("DsGlobal").Alias = "aaa" '<<Error Line

thank you
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Rename DataSource Items

Post by Edward »

Hi,

Please modify your code as follows:

Code: Select all

Report.RegData(DsGlobal)
Report.Dictionary.Synchronize()
Report.Dictionary.DataSources.Item("MyDataSourceName").Alias = "NewAliasforDataSourceName"
Report.Dictionary.DataSources.Item("MyDataSourceName").Columns.Item("MyDataColumnName").Alias = "MyNewAliasForColumn"
Thank you.
saidin
Posts: 8
Joined: Thu May 28, 2009 10:28 pm

Rename DataSource Items

Post by saidin »

Hi,

There is a problem.

1- when we use following code:
Report.Dictionary.DataSources.Item("Personal").Alias = "NewPersonalName"
Report.Dictionary.DataSources.Item("Personal").Columns.Item("Code").Alias = "NewPersonalCode"
In Report Design we have:
Personal[NewPersonalName]
Code[NewPersonalCode]

2- when we use following code:
Report.Dictionary.DataSources.Item("Personal").Name = "NewPersonalName"
In Report Design we have:
NewPersonalName[Personal]

but I want user see just :
NewPersonalName

Thank you very much
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Rename DataSource Items

Post by Jan »

Hello,

Use following code:

Report.Dictionary.DataSources.Item("Personal").Name = "NewPersonalName"
Report.Dictionary.DataSources.Item("NewPersonalName").NameInSource = "Personal"

Thank you.
Post Reply