Hi everyone, I'm having trouble populating a DataTable with a database.
[code]
public DataTable GetData()
{
string connectionString =
System.Web.HttpContext.Current.Application["solarsearch_dbConnectionString"].ToString();
SqlConnection commandString =
new SqlConnection(connectionString);
commandString.Open();
string SQL = "select * from enquiry";
SqlCommand objCommand = new SqlCommand(SQL, commandString);
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet DS = new DataSet();
adapter.SelectCommand = objCommand;
adapter.Fill(DS);
DataTable dt = DS.Tables[0];
return dt;
}
[/code]
When I execute the code I get the error by
[code]
string connectionString =
System.Web.HttpContext.Current.Application["solarsearch_dbConnectionString"].ToString();
[/code]
saying Object reference not set to an instance of an object.
Any help please.