I need help. I have a search button and 2 textboxes.Textbox1 should diplay the employee id when the search button is clicked (and it works fine).But I need to automatically see the employee name in textbox2, based on the employee id on textbox1.I'd really appreciate your help. Below is my code:
conn = New SqlConnection("Data Source=MAPOUNDS\SQLEXPRESS;Initial Catalog=HRManagementSystem;Integrated Security=True")
selectQuery = "SELECT * FROM EmployeeRegistration WHERE EmpID Like '" + txtEmpId.Text + "' AND FullName = '" & txtEmpName.Text & "'"
cmd = New SqlCommand(selectQuery, conn)
dr = cmd.ExecuteReader
If dr.Read Then
txtEmpName.Text = txtEmpId.SelectedText("textbox2 should display employee name based on emp id entered on textbox1").
When i put the employee id and click on the search button, txtEmpid shows the emp id in the textbox. What i need is for txtEmpName to automatically show the Name of the matching EmpId in txtEmpName whenever the txtEmpId is shown.
Ok i modified the code and its like:
selectQuery = "SELECT EmpID FROM EmployeeRegistration WHERE EmpID Like '" + txtEmpId.Text + "'"
txtEmpId should return correct id from database and txtEmpName should automatically show the matching Employee Name.