Connectionstring

Stimulsoft Reports.WEB discussion
nabilfaouzi
Posts: 7
Joined: Wed Mar 18, 2009 5:57 pm
Location: maroc

Connectionstring

Post by nabilfaouzi »

hi, i want to ask how to give a dynamic connectionString to stimulsoftwebDesigner like the one gaves in VB.NET "|DataDirectory|/db.mdf" which enable to us place anywhere our project without change the connectionString thanks for all.(Excuse me for my bad language cause i'm not english)
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Connectionstring

Post by Jan »

Hello,

You can use following code:

Code: Select all

report.Databases.Clear();
report.Databases.Add(new Stimulsoft.Report.Dictionary.StiOleDbDatabase("NameInReport", ConnectionString);
Thank you.
nabilfaouzi
Posts: 7
Joined: Wed Mar 18, 2009 5:57 pm
Location: maroc

Connectionstring

Post by nabilfaouzi »

My ConnectionString in Report Designer is AttachDbFilename=H:\Projet\notes\App_Data\gestion_notes.mdf. if i move my database to another directory (E : for exemple) the connection of report is failed cause it can't find database. i want to give a default directory like asp.net the string of sqlconnection is |data directory|/db.mdf. thanks for your reply.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Connectionstring

Post by Jan »

Hello,

You can use following code:

Code: Select all

string connectionString= string.Format("AttachDbFilename={0}\gestion_notes.mdf", Stimulsoft.Report.StiConfig.ApplicationDirectory);
report.Databases.Clear();
report.Databases.Add(new Stimulsoft.Report.Dictionary.StiOleDbDatabase("NameInReport", ConnectionString);

Thank you.
nabilfaouzi
Posts: 7
Joined: Wed Mar 18, 2009 5:57 pm
Location: maroc

Connectionstring

Post by nabilfaouzi »

thanks again for your reply, i want more details about the last message. i copy the code in report, i copy it into vb.net but it doesn't work. i don't know how it work.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Connectionstring

Post by Jan »

Hello,

You have compilation errors?

Thank you.
nabilfaouzi
Posts: 7
Joined: Wed Mar 18, 2009 5:57 pm
Location: maroc

Connectionstring

Post by nabilfaouzi »

thanks mrs jan i've resolved the probleme thank you for your help and for your service
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Connectionstring

Post by Jan »

Hello,

Let me know if you need any help.

Thank you.
anonay
Posts: 11
Joined: Sun May 03, 2009 10:10 pm
Location: Malaysia

Connectionstring

Post by anonay »

Can you please explain in greater details about the "NameInReport".

We are currently using CR 8.5 Developer version for all our ASP.Net reporting and we are not happy with the licensing issue and frequent rebooting of the server to release the license should it hit the max - which is 5. Our database is MSSQL 2005 and uses SQLConnection for all reporting purposes. Don't mind using ODBC if it is appropriate. Anyway, we found your product easy to use and develop reports, however, 2 areas we seem to be lost at the moment.

1. Our applications allow user to choose the database they which to logon to. So, the database name changes, depending on the one the user chooses. So, the connection string for the Stimulus report.web must change accordingly. So, how can this be done? We supposed this is similar to the question posted earlier.

We have a lot of sub-reports. Do we need to connect the sub-report data sources as the way CR require us to though the main report is already connected?


2. How to programmatically pass values to filters and parameters?


We are seriously contemplating to change our report writer to others as long as we can have the answers for the above clearly stated how we can overcome it without must changes to our current web forms.


Regards,

KW
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Connectionstring

Post by Jan »

Hello,
Can you please explain in greater details about the "NameInReport".
It s name which you give to our connection in report.
1. Our applications allow user to choose the database they which to logon to. So, the database name changes, depending on the one the user chooses. So, the connection string for the Stimulus report.web must change accordingly. So, how can this be done? We supposed this is similar to the question posted earlier.
Yes you need similar code:

Code: Select all

report.Databases.Clear();
report.Databases.Add(new Stimulsoft.Report.Dictionary.StiOleDbDatabase("NameInReport", ConnectionString);
You can use name of connection in report and any connection string.
We have a lot of sub-reports. Do we need to connect the sub-report data sources as the way CR require us to though the main report is already connected?
You don't need do something with sub-reports.
2. How to programmatically pass values to filters and parameters?
Declare in report dictionary variable. After then in filter please use expression something like this:

customers.name == variable

After then you can use following code for variable initialization in report:

Code: Select all

report["variable"] = "test";
Thank you.
Post Reply