changing table to view...

Stimulsoft Reports.NET discussion
Post Reply
raja
Posts: 12
Joined: Wed Aug 08, 2007 6:32 am

changing table to view...

Post by raja »

We design reports aginst sql tables. But when we render it programmatically we want to change all those reports to use Views. But it is not working, here is how my code looks like,

StiDataSourcesCollection collectionDS = stiReport1.Dictionary.DataSources;
foreach (StiDataSource ds in collectionDS) {
if (ds.Name.ToLower() == "asset") {
ds.Name = "v_Asset1998011";
}
if (ds.Name.ToLower() == "location") {
ds.Name = "v_Location1998001";
}

I get all kinds of error. Can someone help me how to do this.
Note: Table and View are having exact columns and everything..
Thanks
raja
Posts: 12
Joined: Wed Aug 08, 2007 6:32 am

changing table to view...

Post by raja »

I think i figured it out... here is the modified code that works...

StiDataSourcesCollection collectionDS = stiReport1.Dictionary.DataSources;
foreach (StiSqlSource ds in collectionDS) {
if (ds.Name.ToLower() == "asset") {
ds.SqlCommand = ds.SqlCommand.ToLower().Replace("asset", "v_Asset1998011");
}
if (ds.Name.ToLower() == "location") {
ds.SqlCommand = ds.SqlCommand.ToLower().Replace("location", "v_Location1998001");
}
}

Post Reply