With a huge thanks to preciousbetine I can now select a name from a ComboBox which will display the other column entries in TextBoxes, but now I'm trying to figure out how to delete the row from the database and update it immediately within the ComboBox after clicking Button1, my current code does nothing(for Button1).
Public Class Form1
Dim dt As New DataTable
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim con As New SqlConnection("Data Source=xxxx\sqlexpress;Initial Catalog=ltLeavers;Integrated Security=True")
Dim da As New SqlDataAdapter("SELECT * FROM dbo.ltData", con)
da.Fill(dt)
ComboBox1.DisplayMember = "DISPLAY_NAME"
ComboBox1.DataSource = dt
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim con As New SqlConnection("Data Source=xxxxx\sqlexpress;Initial Catalog=ltLeavers;Integrated Security=True")
Dim del As New SqlDataAdapter("DELETE * FROM dbo.ltData where DISPLAY_NAME='" & ComboBox1.SelectedIndex & "'", con)
MsgBox("Thank your for your submission.", MsgBoxStyle.OkOnly, "Success!")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = CStr(dt.Rows(ComboBox1.SelectedIndex)("EMAIL_ADDRESS"))
TextBox3.Text = CStr(dt.Rows(ComboBox1.SelectedIndex)("OFFICE"))
TextBox2.Text = CStr(dt.Rows(ComboBox1.SelectedIndex)("DEPARTMENT"))
TextBox12.Text = CStr(dt.Rows(ComboBox1.SelectedIndex)("NEG_ID"))