asp.net - Format of the initialization string does not conform to specification starting at index 0 visual web developer -


i have read several of responses error , have tried of them without success.

here have in web.config file:

<connectionstrings>     <add name="srm_metricconnectionstring" connectionstring="data source=c3srmsql01t;initial catalog=srm_metric;persist security info=true;user id=**;password=**"         providername="system.data.sqlclient" />  </connectionstrings> 

here call in aspx.cs:

    private void bindgridview()     {          // connection string web.config.           // when use using statement,           // don't need explicitly dispose object in code,           // using statement takes care of it.          using (sqlconnection conn = new sqlconnection("srm_metricconnectionstring"))          {              // create dataset object.              dataset dsanno = new dataset(); 

in of responses sqlconnection(configurationmanager.connectionstrings["testdataconnectionstring"].tostring()); seems format. when response configurationmanager not valid in context.

here using declarations using:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data; using system.data.sqlclient; using system.web.security; using system.data.sql; 

any insight appreciated. behind on getting work.

you must use same name in web.config , code behind connectionstrings name.

string constr = configurationmanager.connectionstrings["srm_metricconnectionstring"].tostring(); using (sqlconnection conn = new sqlconnection(constr)) {   // ... 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -