>>DdlUsers.DataSource = ScrapDB.GetUsers(); >>DdlUsers.DataTextField = “UsersID”; >>DdlUsers.DataBind(); >> >>ScrapDB.CloseReader; >>>>The code fires and populates ddlUsers. An error is thrown in Public static CloseReader() // Under CloseReader(), in my data class and the message is ”“Class, struct, or interface method must have a return type”.
>>Public void CloseReader()
>>{
>> UsersReader.Close();
>>}
>>
>>Again ddlUsers loads and it throws an error on the form at ScrapDB.CloseReader; and the error is:>>>public class ScrapDB >>> { >>> public sqldatareader UsersReader >>> >>> 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 ; >>> >>> >>> >>> >>> >>> } >>> public static CloseReader() >>> { >>> UsersReader.Close() ; >>> >>> } >>> >>>} >>> >>> >>> >>> >>>