Hi, I am rather new to programming. I have a stored procedure that simply reads a 'CourseCode' from a Course table, the stored procedure code is as follows:

--------------------------------------------
ALTER PROCEDURE dbo.Courses

AS
SELECT CourseCode
FROM Course
RETURN
---------------------------------------------

I have C# code in the code behind page to try and popuate a dropdownlist with a list of CourseCodes, it is as follows:

public void getCourseDropDown()
        {
            try
            {
                command = new SqlCommand("Courses", myConnection);
                myConnection.Open();
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                {
                    DD_Course_uploadBrief.Items.Add(new ListItem(reader("CourseID".ToString())));
                }
                reader.Close();
            }
            catch (Exception objException)
            {
                //Display the exception message 
                string strError = objException.Message;
                if ((objException.InnerException != null))
                {
                    strError += objException.InnerException.Message;
                }
            }
            finally
            {
                // Clean Up 
                reader = null;
            }
        }

------------------------------------------------------------------------------
When I build the asp.net website application I get the following error:

'reader is a field but is used like a method'

I would be very grateful for any help you all may have,

thanks in advance :)

Post moved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.