prasanna shah

prasanna shah

  • 1.9k
  • 8
  • 5.8k

ConfigurationManager.appSettings error

Jun 10 2016 1:04 PM
namespace 
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
 
 
app1.config
<appSettings>
<add key="myconnection" value="Data Source=ps\sqlexpress; Initial Catalog=class; Integrated Security=True;"/>
</appSettings>
 
BllStudent.cs
public class BllStudent
{
static string connectionStr = ConfigurationManager.appSettings["myconnection"];
public DataTable getStudents()
{
SqlConnection con = new SqlConnection(connectionStr);
string sql = "select * from tbl_student";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "stu");
return ds.Tables["stu"];
}
public static string ConfigurationManager { get; set; }
public string System { get; set; }}
}
 
error: 'string' does not contain a definition for 'appSettings' and no extension method
'appSettings' accepting a first argument of type 'string' could be found (are you missing
a using directive or an assembly reference) 
 
Hi, this is my problem. Any if got any solution for this please help.
 
Thank you
 
 
 
 

Answers (4)