Re: datareader reader questions
- From: "Mike" <Mike@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Aug 2005 04:25:04 -0700
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();
> > }
>
>
>
.
- References:
- datareader reader questions
- From: Mike
- Re: datareader reader questions
- From: W.G. Ryan MVP
- datareader reader questions
- Prev by Date: Re: Object instantiation in C#
- Next by Date: itextsharp, text not printing
- Previous by thread: Re: datareader reader questions
- Next by thread: Writing to a Process
- Index(es):
Relevant Pages
|