Page 1 of 1

How to 'delete' connection if the user can't access that db

Posted: Mon Dec 16, 2013 4:37 pm
by theregister
If we have a dictionary, with several db connections, and the user can't connect to a certain db, then the program will show him an error because of the Initial catalog of the connection string. So how can we 'delete' programatically a db connection from the dictionary, without actually having to remove it from the dictionary, but rather when the program loads?

Re: How to 'delete' connection if the user can't access that

Posted: Tue Dec 17, 2013 12:16 pm
by HighAley
Hello.

Sorry, maybe we did not exactly understand your question. Could you explain your issue more detailed?

Thank you.

Re: How to 'delete' connection if the user can't access that

Posted: Wed Dec 18, 2013 1:57 am
by theregister
Well it's there a way to 'delete' stuff from the dictionary via code? Not like edit the dictionary so it doesn't contain a certain connection anymore, just as if the user clicked on it and chose delete.

Re: How to 'delete' connection if the user can't access that

Posted: Thu Dec 19, 2013 1:02 pm
by HighAley
Hello.

You could use next code to remove any connection:

Code: Select all

report.Dictionary.Databases.Remove(report.Dictionary.Databases["Connection"]);
Thank you.

Re: How to 'delete' connection if the user can't access that

Posted: Sat Dec 21, 2013 7:55 pm
by theregister
I tried this and when the program loads it shows a little X next to the database icon, I thought it was supposed to remove the connection?

Re: How to 'delete' connection if the user can't access that

Posted: Tue Dec 24, 2013 5:55 am
by HighAley
Hello.
theregister wrote:I tried this and when the program loads it shows a little X next to the database icon, I thought it was supposed to remove the connection?
Then you should remove DataSource too with next code:

Code: Select all

report.Dictionary.DataSources.Remove(report.Dictionary.DataSources["DataSource1"]);
Thank you.