I am totally new to Windows programming so i don’t know how to access connection string in Class.cs file as we can in web application as follow:
public DataTable Client_Login_Check(string Email, string Password)
{
DataTable dt = new DataTable();
try
{
object[] objParam = new object[2];
objParam[0] = Email;
objParam[1] = Password;
return dt = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["GL"], "GreenLight_Users_LoginCheck", objParam).Tables[0];
}
catch (Exception ex)
{
OutputMessage = ex.Message;
}
return dt;
}
I have added “System.Configuration” namespace…But still i am not getting ConfigurationManager in help. Please help me..
Apart from adding a reference to
System.Configuration.dllin the project, you will also need to add ausingdeclaration for the namespace in the file:Note:
You should be using
ConfigurationManager.ConnectionStrings["GL"].ConnectionStringand have the connection string in theconnectionStringsconfiguration section, not in theappSettingssection.