when hosted site need change connection string.i have 2 connection string(for test on local computer,for hosting) can possible make switching connection string occurs automatically?
add reference add system.configuration:-
use connection string;
system.configuration.configurationmanager.connectionstrings["connstr"].connectionstring;
place code in web config file;
<connectionstrings> <add name="connstr" connectionstring="server=localhost; database=foo; integrated security=true" ; providername="system.data.sqlclient" /> </connectionstrings>
have different connection strings in local , hosting once,after don't upload web config file hosting unless have to.
Comments
Post a Comment