I am trying to read a connection string from the application configuration file.
But keep receiving an error:
The name ConfigurationManager does in exit in current context.
After googling the error, I added ConfigurationManager to my project. But I still get the same error.
My code:
string sqlConStr = ConfigurationManager.ConnectionStrings["AppConnectionString"].ToString();`
My application config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="AppConnectionString" connectionString="SERVER=1894; Database=db; UID=loss; PWD=where;encrypt=no;enlist=false" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>