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=&quot;data source={0}\{1};initial catalog=magiqdatabase;integrated security=true;multipleactiveresultsets=true;app=entityframework&quot;"           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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -