Marsharks
Marsharks

Reputation: 400

Windows Application ignores app.config and uses something to connect to local database

The application sits on a virtual environment and when I remote in and run the application, it connects to the remote database. However, when I remote in with a service account and double click the same .exe, it tries to connect to the local host database and ignores the app.config. The code is the same, only the login name I use is different. The login I use is part of the local admin group. Any ideas?

Upvotes: 0

Views: 312

Answers (2)

Marsharks
Marsharks

Reputation: 400

In the logic of the code it was doing a comparison of the SQL server setting in the config (Settings), which was entered in lower case, against the list of SQL servers (all in upper case). Since it couldn't find any match, the datasource was blank [datasource=;],hence causing the code to look local. My fix was to use String.Compare and ignore the case, which created the match and I was able to connect to the remote SQL server.

Upvotes: 0

competent_tech
competent_tech

Reputation: 44921

You haven't indicated whether or not this is the case in your question, but my first suspicion is that you are storing the connection strings in settings, but the connection string has been marked as a user-specific setting.

Upvotes: 1

Related Questions