Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Compare value from database

Compare value from database

Scheduled Pinned Locked Moved Visual Basic
databasehelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yaminilathatv
    wrote on last edited by
    #1

    Hi everyone I am trying to compare userid i.e, if the user exists I want to display the message.I am getting error when comparing the text in the textbox and the text from the database.Please tell me how to convert the value into string. the code is as follows... cmd.commandtext="select user from reg" da.selectcommand=cmd da.fill(ds,"reg") for each dr in ds.tables("reg").rows If textbox1.text=dr.item(0) then msgbox("UserExists") endif next thanxin advance yamini

    M G 2 Replies Last reply
    0
    • Y yaminilathatv

      Hi everyone I am trying to compare userid i.e, if the user exists I want to display the message.I am getting error when comparing the text in the textbox and the text from the database.Please tell me how to convert the value into string. the code is as follows... cmd.commandtext="select user from reg" da.selectcommand=cmd da.fill(ds,"reg") for each dr in ds.tables("reg").rows If textbox1.text=dr.item(0) then msgbox("UserExists") endif next thanxin advance yamini

      M Offline
      M Offline
      Muhammad Javed Khan
      wrote on last edited by
      #2

      may be "user" field have null values thats y it will be giving error Try this: cmd.commandtext="select user from reg" da.selectcommand=cmd da.fill(ds,"reg") for each dr in ds.tables("reg").rows If textbox1.text= (dr.item(0) & "") then msgbox("UserExists") endif next

      1 Reply Last reply
      0
      • Y yaminilathatv

        Hi everyone I am trying to compare userid i.e, if the user exists I want to display the message.I am getting error when comparing the text in the textbox and the text from the database.Please tell me how to convert the value into string. the code is as follows... cmd.commandtext="select user from reg" da.selectcommand=cmd da.fill(ds,"reg") for each dr in ds.tables("reg").rows If textbox1.text=dr.item(0) then msgbox("UserExists") endif next thanxin advance yamini

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        The data you get from dr.item(0) is of the type Object. That means that you are comparing the values as objects, not strings, and as they are not the same object, the expression never will be true. Convert the object to a string: If textbox1.text = dr.item(0).ToString() then --- b { font-weight: normal; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups