Re: datareader reader questions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks I got how to handle it if it's empty but what about the "Specified
method is not supported" error? Any idea?

this.user.DBID = dr.GetInt16(0); where this field is a number in Oracle
and user.DBID is a property holding an integer.

Thanks for you help
Mike


"W.G. Ryan MVP" wrote:

> Whenever you use a DataReader, you want to make sure you walk through the
> reader.
>
> First though you can check for rows using the HasRows property immediately
> after you call ExecuteReader.
>
> Next, you can walk through each of the records by just using a
>
> while(reader.Read()){
> //Process here
> }
>
> HTH,
>
> Bill
> "Mike" <Mike@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:605338CF-E4AC-4E46-80CB-1C7C07287F7B@xxxxxxxxxxxxxxxx
> >I am trying to use a datareader to retrieve data and set some properties.
> >I
> > am getting a "Specified method is not supported" error on Line xxx. The
> > data
> > base is Oracle 9i and the field is a number is Oracle, which will be an
> > integer.
> >
> > Code below
> >
> > The query will retrieve only one record or the datareader will be
> > (empty?).
> > How do I test for an empty datareader and return a "You're not in the db"
> > exception?
> >
> > Thanks for your replies
> >
> > Mike
> >
> >
> >
> >
> >
> > Code:
> >
> > private void getUserRightsFromDB(string userLogin)
> > {
> > string SQL;
> > SQL = "Select ID, USER_ID, USER_NAME, USER_EMAIL, USER_RIGHTS From ";
> > SQL += "drewermr.TAB_USER_RIGHTS Where USER_LOGIN = '" + userLogin + "'";
> > //Set command type and string for command object
> > this.OraCommAssistLogin.CommandType = CommandType.Text;
> > this.OraCommAssistLogin.CommandText = SQL;
> > //open db
> > this.openDB();
> > dr = this.OraCommAssistLogin.ExecuteReader();
> > dr.Read();
> > //retrieve values from database
> > this.user.DBID = dr.GetInt16(0); // -- Linexxx
> > this.user.UserID = dr.GetInt16(1);
> > this.user.FullName = dr.GetString(2);
> > this.user.EmailAddress = dr.GetString(3);
> > this.user.UserRights = dr.GetString(4);
> > this.closeDB();
> > }
>
>
>
.



Relevant Pages

  • datareader reader questions
    ... I am trying to use a datareader to retrieve data and set some properties. ... base is Oracle 9i and the field is a number is Oracle, ... The query will retrieve only one record or the datareader will be. ... //Set command type and string for command object ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scope, Schedule and Budget.
    ... "Mike Glen" wrote: ... > (tasks, precedences, durations, resource details, resource calendars, ... or will be entered into an Oracle accounting ... >> and actual cost budgets. ...
    (microsoft.public.project)
  • Re: DBD::oracle DBD::ODBC DBI
    ... Tofigh, Mike wrote: ... Perl 5.8, in Solaris 8, running with ORACLE 9i ... The instant client libraries can be installed very easily and can be used independently of Oracle database itself. ...
    (perl.dbi.users)
  • Re: What is the fastest way to pull data from an Oracle table?
    ... This table is coming from an Oracle database. ... When I use the ExecuteReader my assumption is that I still need to ... I can pull the entire table in about 10 seconds. ... Data Retrival using DataReader is the fasted method.... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: What is the fastest way to pull data from an Oracle table?
    ... This table is coming from an Oracle database. ... When I use the ExecuteReader my assumption is that I still need ... I can pull the entire table in about 10 seconds. ... Data Retrival using DataReader is the fasted method.... ...
    (microsoft.public.dotnet.framework.aspnet)