Hi there,
I have a combo box that contains 10 names. For eg. I select John's name. It will retrieve his left250 value from Access database. It will then display as a label. I've managed to do this so far. However, when i add in a new name in the database, the new name does not appear in the combo box. If I delete John's name in the database, the name in the combo box will not be deleted. Instead, when i select John when the program is running, it will show error. I guess i need to add in some codes for my combo box. Cos when i retrieve values, it will retrieve in reference to the selected index of the combo box. How do i update my combo box automatically without having to refresh my vb program?
Here's my codes:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\BIE\Sowmya.mdb;Jet OLEDB:Database Password=****"
con.Open()
sql = "SELECT * FROM thresholdTable"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Sowmya")
con.Close()
s = Me.nameComboBox.SelectedIndex
left250 = ds.Tables("Sowmya").Rows(s).Item("AC250L")
right250 = ds.Tables("Sowmya").Rows(s).Item("AC250R")
Me.Label1.Text = left250
Me.Label2.Text = right250
End Sub