How to return connection string from report?

Stimulsoft Reports.NET discussion
Post Reply
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

How to return connection string from report?

Post by mietzekotze »

Hello guys,

following problem:

we use reports on a web-based setup (access over browser, editing and viewing in browser), that get their data from an mysql database, so we specified the connection string to the database in the report. Now is the problem, that we want to use this ReportTool on multiple systems (servers) and sometimes even mutliples servers on one real machine. To achieve this, we need to edit the connection string, to have the correct server and port-number used. So what i want to do is:
  • Save connection string to variable
  • Replace old server and port with new ons
  • Save new connection string to report

For the last point i found your tutorial in the knowledge-base, so thats not a problem, but i need to know how to get the database connection into a string. I hope you can help me with that problem.

Regards,
Max
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to return connection string from report?

Post by Alex K. »

Hello,

You can use the following code for change the connection string in report:

Code: Select all

((StiMySqlDatabase)report.Dictionary.Databases["ConnectionNameInReport"]).ConnectionString = newConnectionString
Thank you.
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Re: How to return connection string from report?

Post by mietzekotze »

Hello Aleksey,

thanks for your respond.

i know how to change the connection string. What i need is a command that returns me the connection string into a variable for further use.

Like (pseudo-code):

connstr = GetConnectionString()
print connstr
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to return connection string from report?

Post by Alex K. »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?
Why you can't use the following code:
connstr = ((StiMySqlDatabase)report.Dictionary.Databases["ConnectionNameInReport"]).ConnectionString;

Thank you.
mietzekotze
Posts: 39
Joined: Tue Dec 20, 2011 8:07 am
Location: Germany

Re: How to return connection string from report?

Post by mietzekotze »

Hello,

obviously i made an error somewhere. I've tried that, but it didn't work for me (maybe i mistyped) but that code is working now. Thank you very much, that was what i needed.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to return connection string from report?

Post by Alex K. »

Hello,

Always glad to help you!
Let us know if you need any additional help.
Post Reply