Page 1 of 2
Hide Connection String from report designers
Posted: Wed Feb 16, 2011 7:21 pm
by jay@bplogix.com
I am programmatically adding a connection and data source to a report. When the end-users edit the report, I do NOT want them to see the connect string for the connection I added (it has a userid/password in it). I noticed that the StiSqlDatabase has a CanEditConnectionString property but it cannot be set. How can I "hide" this connect string from the report designers. I do want them to be able to add/modify their own connections (to other databases) though.
Also, is there a reference manual for C# for classes like StiDatabase, StiSqlDatabase, StiReport, etc.
thanks!
Hide Connection String from report designers
Posted: Thu Feb 17, 2011 8:53 am
by Alex K.
Hello,
Unfortunately, it is impossible to hide a username and password by standard methods. Also, if you delete the connection string from connection, the user will not be able to add new tables from the database in the data dictionary. If you have a specific data set, with which a user will work, you can create a code of your DataSet and pass it into the report, in this case all the information about the connection will be only in your application.
Thank you.
Hide Connection String from report designers
Posted: Thu Feb 17, 2011 12:06 pm
by jay@bplogix.com
Is there a way to set the connection string with a variable that I set in my C# code prior to designer the report or running the report?
thx
Hide Connection String from report designers
Posted: Fri Feb 18, 2011 8:30 am
by Alex K.
Hello,
You can set the connection string with the following code:
Code: Select all
((StiSqlDatabase)report.Dictionary.Databases["Connection"]).ConnectionString = connectionString;
Thank you.
Hide Connection String from report designers
Posted: Fri Feb 18, 2011 12:00 pm
by jay@bplogix.com
In design mode ... the users would be able to "see" the actual connection string then, right? Is there a way to set the connection string using a variable so it looks something like this:
((StiSqlDatabase)report.Dictionary.Databases["Connection"]).ConnectionString = "{MyConnectString}";
And then set the "variable" MyConnectString in C#. Then when users design the report ... they will see a connect string of {MyConnectString} which would be evaluated at runtime.
Is that possible?
Thanks!
Hide Connection String from report designers
Posted: Mon Feb 21, 2011 4:28 am
by Alex K.
Hello,
It will not be possible to use a variable. As an option you can disable correction of a connection and hide the Code tab. In this case, the user will not see the connection string.
Code: Select all
report.Dictionary.Restrictions.Add("Connection", StiDataType.Database, StiRestrictionTypes.DenyEdit);
StiOptions.Designer.CodeTabVisible = false;
Thank you.
Hide Connection String from report designers
Posted: Mon Feb 21, 2011 5:08 am
by JorisWils
Hi
You want to hide the connectionstring from designers, ( end users can't edit the .mrt anyway ... right? )
Maybe this is an option.
What we do is the following:
- Provide your designers a sample XML dataset and schema. (
http://msdn.microsoft.com/en-us/library ... 80%29.aspx )
- Your designers can now design a report by adding an XML datasource.
- From code ... just change the datasource to your SQL server
The tool that makes our report actually has an option to save the dataset to xml that was especially made for our report designers. We've been using this procedure for 2 years now and are quite happy with it

Hide Connection String from report designers
Posted: Mon Feb 21, 2011 6:35 am
by Alex K.
Hello,
Thank you for sharing your experience with other users. Have a nice day!
Hide Connection String from report designers
Posted: Fri Mar 04, 2011 6:58 pm
by jay@bplogix.com
Good idea, JorisWils.
Based on your idea, I am actually dynamically creating a C# DataSet as a "dummy" conection and datasource(s) when the user designs the report (in Reports.Web designer). Then when the report runs, I want to drop all of my "dummy" connections/datasources, but keep any that the user added manually (to an external DB, to XML, etc), and then re-create the connections/datasources pointing to the "real" database.
I will name the "dummy" connection (the name of the DataSet) something like "BUILTIN_abc" so that at runtime I know which one to replace. I can iterate through the Dictionary.Databases.Items and find the name of the connection (and drop the "BUILTIN_abc one), but when I iterate through the Dictionary.DataSources, I only see the name of the datasource ... not the dictionary it was contained in. How do I drop ONLY the datasources that were created under the BUILTIN_abc dictionary?
"From code ... just change the datasource to your SQL server" ... how can I re-map the dummy connection from a C# DataSet into a SQL Connection to a "real database".
Thanks!
Hide Connection String from report designers
Posted: Sat Mar 05, 2011 2:00 am
by Alex K.
Hello,
If we understand your problem correctly, for remove the "dummy" datasources which contains "BUILTIN", you can use the following code:
Code: Select all
StiDataSourcesCollection sCollect = new StiDataSourcesCollection(new StiDictionary());
foreach (StiDataSource source in report.Dictionary.DataSources)
{
if (!source.Name.Contains("BUILTIN"))
sCollect.Add(source);
}
report.Dictionary.DataSources = sCollect;
Thank you.