c# - connectionString server name not picked up -
as per reference (modifying connection string variables), app.config
file line of interest:
<connectionstrings> <add name="magiqdatabaseentities" connectionstring="metadata=res://*/unpalangimodel.csdl|res://*/unpalangimodel.ssdl|res://*/unpalangimodel.msl;provider=system.data.sqlclient;provider connection string="data source={0}\{1};initial catalog=magiqdatabase;integrated security=true;multipleactiveresultsets=true;app=entityframework"" providername="system.data.entityclient" /> </connectionstrings>
(note {0}
, {1}
)
i have following in .cs file:
string connectionstring = string.format(configurationmanager.connectionstrings["magiqdatabaseentities"].connectionstring, "hppc", "newinstance");
the server hppc\newinstance
as per reference (can't make connection string in c#), thought backslash problem. have tried double backslash, still can't establish connection.
the connection definitely works when data source
hardcoded hppc\newinstance
.
thank you.
why not set data source = {0}
and in c# code this:
string connectionstring = string.format( configurationmanager.connectionstrings["magiqdatabaseentities"].connectionstring, string.concat("hppc", @"\", "newinstance"));
Comments
Post a Comment