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

Stimulsoft Reports.NET discussion
Post Reply
theregister
Posts: 53
Joined: Wed Nov 27, 2013 5:24 pm

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

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post by HighAley »

Hello.

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

Thank you.
theregister
Posts: 53
Joined: Wed Nov 27, 2013 5:24 pm

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

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post 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.
theregister
Posts: 53
Joined: Wed Nov 27, 2013 5:24 pm

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

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post 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.
Post Reply