I'm writing a code to retrieve the StudentID from a table in my database and then display it in a textbox. The code to retrieve the ID is on one form and I want the value to display in the textbox in another form. The code that I'm using does not display an error but the value is not displayed in the textbox. This is the code I'm using, it could be completely wrong but I'm not sure:
Dim SubjectHomepage As New SubjectHomepage SubjectHomepage.Show() Me.Close() provider = "Provider=Microsoft.ACE.OLEDB.12.0;" dataFile = "Data Source=|DataDirectory|\UserDatabase.accdb" connString = provider & dataFile Using conn As OleDbConnection = New OleDbConnection(connString) Dim cmd As New OleDbCommand( _ "SELECT StudentID FROM Users " & _ "WHERE Username='" & LogIn.UsernameTextBox.Text & "'", conn) conn.Open() SubjectHomepage.StudentIDTextBox.Text = cmd.ExecuteScalar() conn.Close() End Using
Thanks in advance.
Edited 1 Year Ago by leyla