Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SqlDataReader Data Class Question
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Web forms
Title:
SqlDataReader Data Class Question
Environment versions
Environment:
C# 1.1
OS:
Windows 2000 SP3
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00954923
Message ID:
00954923
Views:
57
Here is what I came up with and I have a question about GetUsers().
public class ScrapDB
	{

		public static SqlConnection GetConnection()
		{
			string connectionString = ConfigurationSettings.AppSettings["connectionString"];
		
			return new SqlConnection(connectionString);
	
		}

	public static SqlDataReader GetUsers()
				{
			// Use a SqlDataReader to fill ddlUsers...
			SqlDataReader UsersReader = null ;
				
					SqlConnection UsersConnection = GetConnection() ; 
					
					string selectStatement = "SELECT UserID "
						+ "FROM UserInfo ";
			
					SqlCommand selectCommand = new SqlCommand(selectStatement, UsersConnection);
					//SqlDataReader UsersReader;
			
					UsersConnection.Open();
					UsersReader = selectCommand.ExecuteReader(CommandBehavior.CloseConnection);
					UsersReader.Read() ;
					return UsersReader ;
				
				
				        UsersReader.Close() ;
			
		

			}
}
Notice the line of code at the end of return UsersReader.

UsersReader.Close;

The puppy complies and runs fine and returns no errors. However, with the form running when I go to the data class I see a blue wavey line (problem). By placing the cursor on top of UsersReader.Close() I have the following message - "Unreachable code detected".

Perhaps I am not there yet but I am close. Should I be concerned about this message? I just do not like it.

Tom
Next
Reply
Map
View

Click here to load this message in the networking platform