Private Sub frmOrganization_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlorganization As String = ""
sqlorganization = " select * from organization"
sqlorganization &= " ORDER BY ORGID"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlprovince_th As String = ""
sqlprovince_th = "SELECT * FROM province ORDER BY PROVINCEID"
da = New SqlDataAdapter(sqlprovince_th, Conn)
da.Fill(ds, "province")
With cboPROVINCE_TH
.DisplayMember = "PROVINCE_TH"
.ValueMember = "PROVINCEID"
.DataSource = ds.Tables("province")
.DataBindings.Add("SelectedValue", ds, "organization.PROVINCEID")
End With
End Sub
Private Sub cboDISTRICT_TH_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDISTRICT_TH.SelectedIndexChanged
Dim sqldistric As String = ""
sqldistric = " select * from district"
sqldistric &= " where PROVINCEID='" & cboPROVINCE_TH.SelectedIndex & "'"
da = New SqlDataAdapter(sqldistric, Conn)
da.Fill(ds, "district")
With cboDISTRICT_TH
.DisplayMember = "DISTRICT_TH"
.ValueMember = "PROVINCEID"
.DataSource = ds.Tables("district")
.DataBindings.Add("SelectedValue", ds, "district.PROVINCEID")
End With
End Sub
Tag : .NET, Ms SQL Server 2008, VBScript, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)