One Report, Different Datasources (Local: Dataset, Remote: SqlServer)

Stimulsoft Reports.NET discussion
Post Reply
qhaut
Posts: 3
Joined: Sat Jul 21, 2007 4:50 am
Location: Austria

One Report, Different Datasources (Local: Dataset, Remote: SqlServer)

Post by qhaut »

Hello all,

I am using StimulReport 2007.1 for .NET 1.1 and have to solve
following situation.

1. I have do design a Report - the underlaying datasource is
a dataset with an inline-scheme and inline-information about
relations as shown in your samples.


ds = new DataSet( "DataSetName" );
r = new StiReport();
r.Load( reportFile );
r.DataSources.Clear();
r.DataStore.Clear();
ds.ReadXml( , XmlReadMode.ReadSchema );
r.RegData( "AnyName", ds );
r.Design( );


This works very well. I am able to design the report and because
of the data within the dataset I can do a preview too!

No problem so far... But now the problems came up...

2. I have to connect the Report to Remote Datasources.
Sample:
server=;database=;trusted_connection=yes
The Server (of course), and the DatabaseName can change. It is guaranteed
that the Tables/Relations are the same - with other data of course - but
the scheme is the same.

How can I solve this?

r = new StiReport();
r.Load( reportFile );
r.DataSources.Clear();
r.Dictionary.Clear();
r.Dictionary.Databases.Add(new StiSqlDatabase("AnyName", ));


I am getting the following Errormessage:
error CS0246: The type or namespace name 'Mis_Kunde'
could not be found (are you missing a using directive or an assembly reference?)

'Mis_Kunde' is a table in the datasource which is available and readable.

Can you point me in the right direction or are the better ways to solve such an issue.

Thank you in advance for your help, Günther
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

One Report, Different Datasources (Local: Dataset, Remote: SqlServer)

Post by Brendan »

Does the report already have the remote Datasource defined and it's that you want to change it's connection string based on a connection string from your client application?

If so then after load call your report.Load(filename) you can get the SqlDatabase datasource from the report and edit it's connection string

Code: Select all

Stimulsoft.Report.Dictionary.StiSqlDatabase sqlDB = report.Dictionary.Databases["MY_DB_NAME"] as Stimulsoft.Report.Dictionary.StiSqlDatabase;
if(sqlDB != null)
{
	sqlDB.ConnectionString = "My Connection String";
}

Also, I think you need to remove the following lines

Code: Select all

r.DataSources.Clear();
r.DataStore.Clear();
unless you need them, but what they are doing is clearing any Datasources you've previously defined in the report.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

One Report, Different Datasources (Local: Dataset, Remote: SqlServer)

Post by Edward »

Please note also the following fact. First your data was in the DataSource in DataSet. Then you added a new SQLConnection to your new data. But now there should be a SQL based DataSource for correct access to the remote data.
So you need add a new SqlDataSource object with correct SQL to the report's Dictionary.

Thank you.
Post Reply