Running C# Database application for multiple clients

lional

Well-known member
Joined
Nov 29, 2018
Messages
55
Programming Experience
Beginner
Hi

I have a database application written in C# for a theological college. If I want to use the same application for another college at a different site with another database, what is the best way to connect to the database.

I currently use a connection string but that means changing the string for each college.

Is there a way to have a generic connection method? Is the best to use odbc to connect to the database or is there a better method.

I am trying to make the application portable without having to make changes for each college.

Just point me in the right direction, I don't believe in being given the code, it is not the way to learn.

Thank you, much appreciated.
 
If the database is not at the same location in each case then you have no choice but to change the connection string. If, for instance, a database will be created on a server at each site and that server may have a different name each time then you have to provide that name each time. You could use ODBC and specify a DSN, but then you need to save a new DSN on each machine with the connection details, so you just push the issue back one step. The only way that helps is if each machine already has a DSN for that server and you can then specify the database after connecting. If your database is local to the application then you wouldn;t have that same issue, because you can use the "|DataDirectory|" placeholder in your connection string and it will be resolved at run time. The other option is to build the connection string at run time from values provided by the user and saved locally, perhaps using application settings.
 
You can create one table where you can put mapping of your database string along with your identification id. At the time of running application read value from that table.
 
You can create one table where you can put mapping of your database string along with your identification id. At the time of running application read value from that table.
That would require you to have one master database that every user at every site connected to first to then get the connection details for their own database. It would also mean that you'd still have to edit the site ID after deployment, so why not just edit the connection string?
 
Personally, I'm kind of worried that you have 3 different organizations sharing a single database. I hope that database is not sitting naked on the Internet. Recall the recent (NoSQL ?) database breaches where some people had left databases exposed naked on the Internet -- and even worse they left the default sign in accounts active.
 
Personally, I'm kind of worried that you have 3 different organizations sharing a single database.
As far as I can tell, that's not the case. If it was, there'd be no need for the question because everyone would be using the same known connection details. From my reading, this application will be used at multiple sites and each site will have their own copy of the database in their own choice of location, which is why the connection details need to be different for each site. The very first paragraph of the question says "another database" so that kinda rules out a "single database".
 
Thanks. I missed that part of the OP.
 
Back
Top Bottom