Results 1 to 2 of 2

Thread: Get data in oledb command

  1. #1

    Thread Starter
    Hyperactive Member marniel647's Avatar
    Join Date
    Aug 2010
    Location
    MSDN Library
    Posts
    259

    Get data in oledb command

    hello guys im having a problem how to compare the result of the query..

    for example i have a command "Select RemainTime from time where username = username"

    how do i get the result of the query and compare it to a string
    this is what i do..

    vb.net Code:
    1. dim remain as string
    2. 'and then the command
    3. using reader as oledb.oledbdatareader = command.executereader()
    4. remain = reader.getvalue(0)
    5. if remain = textbox1.text
    6.   'statements
    7. else
    8. 'statements
    9. end if
    10. end using

    is this correct..?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Get data in oledb command

    If you want to execute a query to get a single value then call ExecuteScalar rather than ExecuteReader. It will return the actual value, rather than a DataReader. For an example, follow the CodeBank link in my signature and check out my thread on Retrieving & Saving Data.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width