c# - unable to get correct ConnectionString from app.config -
c# - unable to get correct ConnectionString from app.config -
let's have 2 folder > 1>original 2> copied. have copied total visual project folder1 folder2 , changed connectionstring path respect folder2.
folder 1 > <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionstrings> <add name="mydata" connectionstring="data source=.\sqlexpress;attachdbfilename=e:\folder1\mydata.mdf;integrated security=true;user instance=true" /> </connectionstrings> </configuration>
connection manager
string connectionstring = configurationmanager.connectionstrings["mydata"].connectionstring;
,
after coping folder 2 chanaged path > <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionstrings> <add name="mydata" connectionstring="data source=.\sqlexpress;attachdbfilename=e:\folder2\mydata.mdf;integrated security=true;user instance=true" /> </connectionstrings> </configuration>
now, when seek access database refers "folder1" database not current "folder2" database.
note:
in "folder1" have published app , after copied "folder2", can 1 please point out issue?
if connectionstring shows folder1 in path, that's problem: hasn't been updated. create sure saved file, , search entire solution occurences of "folder1".
if doesn't work (although should), place breakpoints connection db made, , connectionstring assigned value, , check path @ every breakpoint see whether contains folder1 or folder2.
c# sql connection-string
Comments
Post a Comment