2 Replies - 492 Views - Last Post: 06 October 2012 - 01:56 PM Rate Topic: -----

#1 faisalmukhtarch  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 06-October 12

unable to load proper data using MS Access database in VB.net

Posted 06 October 2012 - 01:19 PM

Iam using this code to get the Staff ID from which i login but iam getting the Staff Name of some other data.
Help needed
con.Open()
        sql2 = "Select * FROM Staff "
        cmd = New OleDbCommand(sql2, con)
        dr = cmd.ExecuteReader
        dr.Read()
        txtStaffID.Text = dr.Item("Staff ID")
        dr.Close()
        con.Close()

Is This A Good Question/Topic? 0
  • +

Replies To: unable to load proper data using MS Access database in VB.net

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 769
  • Joined: 19-October 11

Re: unable to load proper data using MS Access database in VB.net

Posted 06 October 2012 - 01:56 PM

Try to change your lines 5 and 6 with:
        'make sure you have multi-line textbox
        While dr.Read()

            txtStaffID.Text &= dr.Item("Staff ID")

        End While


Was This Post Helpful? 0
  • +
  • -

#3 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: unable to load proper data using MS Access database in VB.net

Posted 06 October 2012 - 01:56 PM

I see two things there:
- First, did you say "but iam getting the Staff Name"? I think you mean staff id right?

- Then you are querying all rows rows, how can you get the one you logged in by? Simply here you will have to catch the id of the one who loged in in login process, then store it in a variable for letter usage. This will simplify a lot of those troubles...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1