Imports System.Data.SqlClient Public Class Form3 Dim cn As SqlConnection Dim cmd As SqlCommand Dim dr As SqlDataReader Dim da As SqlDataAdapter Dim ds As New DataSet Dim dt As New DataTable Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn = New SqlConnection("server=localhost;uid=sa;pwd=sa;database=RKPlastics") cn.Open() da = New SqlDataAdapter("select * from trial order by name ASC", cn) da.Fill(dt) ComboBox1.DataSource = dt ComboBox1.DisplayMember = "name"; ComboBox1.ValueMember = "id"; ComboBox1.Text = "select value"; ComboBox1.SelectedValue = 1 cn.Close() End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Dim selectedEmployee = CType(ComboBox1.SelectedItem, String) TextBox1.Text = TextBox1.Text & Microsoft.VisualBasic.vbCrLf & selectedEmployee End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)