•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 392,045 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,256 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 478 | Replies: 2
![]() |
•
•
Join Date: Mar 2008
Posts: 37
Reputation:
Rep Power: 1
Solved Threads: 0
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:
------------------------------------------------------------------------------
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
--------------------------------------------
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
Last edited by Elmo_loves_you : Apr 3rd, 2008 at 5:14 am. Reason: Trying to wrap code in tags
Please move your thread to ASP.NET forum http://www.daniweb.com/forums/thread117180.html
reader.GetString(coulmnNumber); or
reader.GetInt32(columnNumber); based on your column data type and its number.
reader.GetString(coulmnNumber); or
reader.GetInt32(columnNumber); based on your column data type and its number.
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
access advice breach broadband business classification code combo crime cult of the dead cow daniweb data data protection data transfer database drive dropdownlist encryption europe forensic forensics fun google government hacking hard hardware help hitachi hp industrial espionage information internet it mobile module net news payment services privacy protection reuse search security storage terabyte tutorials and more tv web wikipedia
- Previous Thread: script pbm
- Next Thread: 301 redirect on a non-aspx page?



Linear Mode