N
nigelsvision
Guest
Hi,
I have a login form for people to login and get taken to another page. The page they are taken to has a label on it. The logged in user has his, her name put on the label automatically using code. The name of the label is "UserNameLoggedInLabel"
What I am trying to achieve is:
what ever name is on the label to search my database for that user and put there details in to the TextBoxes on my form.
So in my access database I have a table called "tblContacts" which has 4 fields
identifier,
UserName,
UserPassword,
UserTimer,
On my form I have 3 TextBoxes I do not want to show "identifier in the "TextBoxes"
TextBox1
TextBox2
TextBox3
On a button click I have inserted this code I am stuck with the SQL I can get it to populate my 3 TextBoxes with the data in my access database. But it only populates my TextBoxes with the data from the first row. I have tried and tried but I need a good solid example of how to achieve this can anyone help me with this line of code I need.
Thanks in advance for any help.
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = " + AppDomain.CurrentDomain.BaseDirectory + "Database1.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT UserName FROM tblContacts Where UserName=UserName;"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "database1")
MsgBox("Database is now open")
con.Close()
MaxRows = ds.Tables("database1").Rows.Count
inc = -1
MsgBox("Database is now Closed")
TextBox2.Text = CStr(ds.Tables("database1").Rows(0).Item(1))
TextBox3.Text = CStr(ds.Tables("database1").Rows(0).Item(2))
TextBox4.Text = CStr(ds.Tables("database1").Rows(0).Item(3))
Continue reading...
I have a login form for people to login and get taken to another page. The page they are taken to has a label on it. The logged in user has his, her name put on the label automatically using code. The name of the label is "UserNameLoggedInLabel"
What I am trying to achieve is:
what ever name is on the label to search my database for that user and put there details in to the TextBoxes on my form.
So in my access database I have a table called "tblContacts" which has 4 fields
identifier,
UserName,
UserPassword,
UserTimer,
On my form I have 3 TextBoxes I do not want to show "identifier in the "TextBoxes"
TextBox1
TextBox2
TextBox3
On a button click I have inserted this code I am stuck with the SQL I can get it to populate my 3 TextBoxes with the data in my access database. But it only populates my TextBoxes with the data from the first row. I have tried and tried but I need a good solid example of how to achieve this can anyone help me with this line of code I need.
Thanks in advance for any help.
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = " + AppDomain.CurrentDomain.BaseDirectory + "Database1.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT UserName FROM tblContacts Where UserName=UserName;"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "database1")
MsgBox("Database is now open")
con.Close()
MaxRows = ds.Tables("database1").Rows.Count
inc = -1
MsgBox("Database is now Closed")
TextBox2.Text = CStr(ds.Tables("database1").Rows(0).Item(1))
TextBox3.Text = CStr(ds.Tables("database1").Rows(0).Item(2))
TextBox4.Text = CStr(ds.Tables("database1").Rows(0).Item(3))
Continue reading...