Imports System
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Configuration
Dim appConn As String = ConfigurationManager.ConnectionStrings("connDB").ToString
Dim Conn As SqlConnection = New SqlConnection(Me.appConn)
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet()
Public Sub showSection()
da = New SqlDataAdapter("SELECT DISTINCT Section From Employee Order By Section", Conn)
da.Fill(ds)
Conn.Close()
cbSection.DataSource = ds.Tables(0)
cbSection.DisplayMember = "Section"
cbSection.ValueMember = "Section"
cbSection.SelectedIndex = -1
End Sub
Private Sub cbSection_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
cbSection.SelectedIndexChanged
If cbSection.SelectedIndex > -1 Then
da = New SqlDataAdapter("SELECT DISTINCT Team From Employee WHERE Section='" + cbSection.SelectedValue.ToString
() + "'", Conn)
da.Fill(ds)
Conn.Close()
cbTeam.DataSource = ds.Tables(0)
cbTeam.DisplayMember = "Team"
cbTeam.ValueMember = "Team"
End If
End Sub
รบกวนด้วยค่ะ ขอบคุณล่วงหน้ามากๆค่า
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2008 (.NET 3.x), Windows