hello, I am trying to connect MS ACCESS 2007 Database with textboxes which will show the info of the users..for example..when I login..I see my info in the textboxes..and when other user logs in..they can see their info..

This is the code I have on load after the window login..

Private Sub frmemp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            cmd = New OleDbCommand("SELECT * FROM employees,username WHERE ID=IDE", conn)
            dr = cmd.ExecuteReader
            While dr.Read()
                txtfn.Text = dr(1)
                txtpro.Text = dr(2)
                txtsa.Text = dr(3)
            End While
        End Try

    End Sub

But this code only shows the last user on the row on the database..It is not changing even other users login..for example...I login and I am the last user on the row..I can see my info but when other user logs in..He just see my info..Not his...

Please help..and thanks in advance..

5 Years
Discussion Span
Last Post by adam_k

employee and username tables are just in one MS Access database, employee is composed of IDE,Full Name,Project and Salary columns and username is composed of ID,user, and pass columns, I want the data of employee to appear in textbox in a window in every user..tnx


Your problem is the query that you are using.

SELECT * FROM employees,username WHERE ID=IDE

What you've done is select everything from both tables and not the info for the current user.
Like I've replied in another thread you've started, store the username of the user logged in in a variable and use that variable when quering the db. Like so:

SELECT * FROM employees,username WHERE ID=IDE and user = '" & username &"'"

If the username contains the username of the current user, then you are done.

PS: It is a bad practise to select all fields when you don't need them.
PS2: Your code didn't just show you the last user in the table. It showed all users in the table, but it stopped updating the textboxes at the last user due to

While dr.Read()

Edited by adam_k: n/a


thank you so much..I removed the while statement already but the info is still not the info of that user..

I have two forms...frmlogin and frmempm.....I put the code at load in frmempm....I need the info of that user who logged in from frmlogin to appear in the textbox at the frmempm...

please help... I have one day left :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.