Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim comboBox As comboBox = CType(sender, comboBox)
Dim selectedEmployee = CType(ComboBox1.SelectedItem, String)
End Sub
Imports System.Data.SqlClient
Public Class Form1
Public data As String = "Data Source=(local);Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=1234"
Public con As New SqlConnection(Data)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim sql As String = "SELECT * FROM test_1"
Dim com As New SqlCommand(sql, con)
Dim dr As SqlDataReader = com.ExecuteReader
Dim total As Double
If dr.HasRows Then
While dr.Read
ComboBox1.Items.Add(dr.Item(1))
End While
Label1.Text = total
dr.Close()
End If
con.Close()
End Sub