Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

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(connectionString);
                  SqlCommand command = new SqlCommand("GetTopNav", connection);
                  command.CommandType = CommandType.StoredProcedure;
                  connection.Open();
                  return command.ExecuteReader(CommandBehavior.CloseConnection);
            }
            private static string connectionString
            {
                  get
                  {
                        return ConfigurationSettings.AppSettings("ConnectionString");
                  }
            }
      }
}

I'm getting error on the following lines:

command.CommandType = CommandType.StoredProcedure;

return command.ExecuteReader(CommandBehavior.CloseConnection);

return ConfigurationSettings.AppSettings("ConnectionString");  //this references the connection string stored in the web.config file

Thanks for any help.
ASKER CERTIFIED SOLUTION
Avatar of athapa
athapa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of -Dman100-

ASKER

Thank you AT,

That corrected the problem.  I appreciate your help.