Page 1 of 1

How to return connection string from report?

Posted: Tue Aug 06, 2013 8:49 am
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

Re: How to return connection string from report?

Posted: Tue Aug 06, 2013 10:01 am
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.

Re: How to return connection string from report?

Posted: Tue Aug 06, 2013 11:29 am
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

Re: How to return connection string from report?

Posted: Wed Aug 07, 2013 9:43 am
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.

Re: How to return connection string from report?

Posted: Wed Aug 07, 2013 9:54 am
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.

Re: How to return connection string from report?

Posted: Wed Aug 07, 2013 11:16 am
by Alex K.
Hello,

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