c# - Connection string not being read from App.config in project -


I am using an abstract class to get the connection string from my App.config file. However the connection comes with the app instead of the string ...

  {data source =. \ SQLEXPRESS; Integrated Security = SSPI; Attach DB Filename = | Data directory ASPANDDB.MDF; User instance = true}   

I do not know where this connection string came from. I do not have SQL Express installed I know that proper app.config can not be used because I added a dummy connection string called foo and when I move through debugging instead of two If I pick up, then only one connection string is raised. It seems that the app is getting a connection string from another app.config!

Here's my class

  using the system; Using System.configuration; Namespace MyApiUpdater.Data {Public abstract class ConnectionAccess {secure string ConnectionString {get {return ConfigurationManager.ConnectionStrings ["MyDatabase"]. ConnectionString; }}}}   

And here my app Config file is

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Configuration & gt; & Lt; ConnectionStrings & gt; & Lt; Add name = "myadabase" connection string = "server = mydbase server; database = myDBName; relationalact = true;" / & Gt; \ & Lt; Add name = "foo" connection string = "server = macetabase server; database = myDBName; trusted connection = true;" / & Gt; & Lt; / ConnectionStrings & gt; & Lt; / Configuration & gt;    

See this:

Also, make sure That you are in the correct config file in Visual Studio because you can unexpectedly grab one by holding one of the wrong folders and by doing so, your app grabs the connection string in machine.config.

See: and look at the file and you will see where the wrong string is coming from.

Additional Tags: web.config

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -