Hi,
Im getting the error "The name 'Application' does not exist in the current context" with the piece of code below. Which is strange becuase i thought application fields were global. Im getting the errors with the server.transfer methods as well.
Im thinking it may have something to do with server paths. The content of the class worked fine in the aspx code behind.
Im a newbie so sorry if this is a 'groaner'.
public class Art_DBQueries
{
public Art_DBQueries()
{
//
// TODO: Add constructor logic here
// Add dtababase connection strings here
}
public void addArticle(string tit, string aut, string des, string con, string dat)
{
SqlDataSource AddArt = new SqlDataSource();
AddArt.ConnectionString = ConfigurationManager.ConnectionStrings[Application["ConnectDB"].ToString()].ToString();
AddArt.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
AddArt.InsertCommand = "AddArticle";
AddArt.InsertParameters.Add("heading", tit);
AddArt.InsertParameters.Add("author", aut);
AddArt.InsertParameters.Add("description", des);
AddArt.InsertParameters.Add("artcontent", con);
AddArt.InsertParameters.Add("datewritten", dat);
int rowsaffected = 0;
try
{
rowsaffected = AddArt.Insert();
}
catch (Exception ex)
{
Server.Transfer("StandardError.aspx");
}
finally
{
AddArt = null;
Server.Transfer("article_abc.aspx");
}
}
}
Im getting the error "The name 'Application' does not exist in the current context" with the piece of code below. Which is strange becuase i thought application fields were global. Im getting the errors with the server.transfer methods as well.
Im thinking it may have something to do with server paths. The content of the class worked fine in the aspx code behind.
Im a newbie so sorry if this is a 'groaner'.
public class Art_DBQueries
{
public Art_DBQueries()
{
//
// TODO: Add constructor logic here
// Add dtababase connection strings here
}
public void addArticle(string tit, string aut, string des, string con, string dat)
{
SqlDataSource AddArt = new SqlDataSource();
AddArt.ConnectionString = ConfigurationManager.ConnectionStrings[Application["ConnectDB"].ToString()].ToString();
AddArt.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
AddArt.InsertCommand = "AddArticle";
AddArt.InsertParameters.Add("heading", tit);
AddArt.InsertParameters.Add("author", aut);
AddArt.InsertParameters.Add("description", des);
AddArt.InsertParameters.Add("artcontent", con);
AddArt.InsertParameters.Add("datewritten", dat);
int rowsaffected = 0;
try
{
rowsaffected = AddArt.Insert();
}
catch (Exception ex)
{
Server.Transfer("StandardError.aspx");
}
finally
{
AddArt = null;
Server.Transfer("article_abc.aspx");
}
}
}