-Dman100-
asked on
problem with the following code
I created the following class file:
public class DataAccess
{
public DataAccess()
{
//
// TODO: Add constructor logic here
//
}
public static SqlDataReader GetDepartments()
{
SqlConnection connection = new SqlConnection(connectionSt ring);
SqlCommand command = new SqlCommand("GetTopNav", connection);
command.CommandType = CommandType.StoredProcedur e;
connection.Open();
return command.ExecuteReader(Comm andBehavio r.CloseCon nection);
}
private static string connectionString
{
get
{
return ConfigurationSettings.AppS ettings("C onnectionS tring");
}
}
}
}
I'm getting error on the following lines:
command.CommandType = CommandType.StoredProcedur e;
return command.ExecuteReader(Comm andBehavio r.CloseCon nection);
return ConfigurationSettings.AppS ettings("C onnectionS tring"); //this references the connection string stored in the web.config file
Thanks for any help.
public class DataAccess
{
public DataAccess()
{
//
// TODO: Add constructor logic here
//
}
public static SqlDataReader GetDepartments()
{
SqlConnection connection = new SqlConnection(connectionSt
SqlCommand command = new SqlCommand("GetTopNav", connection);
command.CommandType = CommandType.StoredProcedur
connection.Open();
return command.ExecuteReader(Comm
}
private static string connectionString
{
get
{
return ConfigurationSettings.AppS
}
}
}
}
I'm getting error on the following lines:
command.CommandType = CommandType.StoredProcedur
return command.ExecuteReader(Comm
return ConfigurationSettings.AppS
Thanks for any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That corrected the problem. I appreciate your help.