sql reader question

Discussion in 'Questions (Windows Mobile)' started by Ricky D, Sep 16, 2008.

  1. Ricky D

    Ricky D Well-Known Member Licensed User

    Hi people,

    in my Taxi app I use a reader to access data from my SQLite database.

    Is there a way to tell if the reader is open? I run into this error

    Cannot set CommandText when a DataReader is active

    I'd like to do something like

    If reader.IsOpen=true Then reader.Close

    before I try to set the command's CommandText method.

    Is there a way to tell if the reader is open?

    If not should I use reader.Dispose to get rid of it and then use reader.New1 when i need to use the reader?

    any help appreciated.

    regards, Ricky

    Edit: tried doing .Dispose then when I need it use .New1. Here is my code

    . other code

    Goto retry

    I find the code at .New1 keeps getting executed once the 1st error is trapped
    Any ideas?
    Last edited: Sep 16, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    After you set the reader's value once you can close it even after it's closed.
    IsNull(reader.value) will return true before you set the reader's value for the first time.

    Something like this should solve your problem:
    If IsNull(reader.value) = false then reader.close
    cmd.CommandText = ...
  3. Ricky D

    Ricky D Well-Known Member Licensed User

    Thanks Erel

    Thanks Erel.

    That works just right :)

    regards, Ricky
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice