Hello.. I want to populate my combobox with the list of banknames available in my database.. I tried doing so but i am getting a blank list.. ie.. shows no value in combobox !! Here is what i tried.. Please help !!
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
Try
'MsgBox("Open")
cn = New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
cn.Open()
cmd = New OleDbCommand("select * from contactinfo", cn)
dr = cmd.ExecuteReader()
While dr.Read()
If Not ComboBox4.Items.Contains(dr("bankname")) Then
ComboBox4.Items.Add(dr("bankname"))
End If
End While
MsgBox("Your Account Created Successfully ")
'MsgBox("Done !!")
Catch myException As Exception
MsgBox("No Record Inserted" + myException.ToString())
Finally
'MsgBox("Closing Connection")
dr.Close()
cn.Close()
End Try
End Sub