c# - Unable to call connection string from web config file -


i want establish connection sql database. want place connection string in web config file. wrote code in web config file as:

<add name="dbcs" connectionstring="data source=sahil-pc\\sqlexpress; database=abadakdb; integrated security=true " providername="system.data.sqlclient"/> 

now, want establish connection in asp.net, wrote method in cs file as:

 private dataset getdata(string procname, sqlparameter param)      {         string cs = configurationmanager.connectionstrings["dbcs"].connectionstring;          sqlconnection conn = new sqlconnection(cs);          sqldataadapter da = new sqldataadapter(procname, conn);          da.selectcommand.commandtype = commandtype.storedprocedure;          dataset ds = new dataset();          da.fill(ds);          return ds;      } 

here, getting error in da.fill(ds) line. says

system.invalidoperationexception: instance failure.

i checked code internet. dont know going wrong. if explicitly write connection string in function works fine. problem connection string in web config file or calling thing web config file. can please me out.

change connection string in web.config to:

"data source=sahil-pc\sqlexpress; database=abadakdb; integrated security=true " providername="system.data.sqlclient" 

in code, \\ resolves \, comes in web.config

the same putting literal @ before string


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -