Private Sub Call_province()
Try
Dim sqlprovince As String = ""
sqlprovince = "SELECT * FROM province"
sqlprovince &= " ORDER BY PROVINCEID"
da = New SqlDataAdapter(sqlprovince, Conn)
da.Fill(ds, "province")
If ds.Tables("province").Rows.Count <> 0 Then
With cboPROVINCE_TH
.DataSource = ds.Tables("province")
.DisplayMember = "PROVINCE_TH"
.ValueMember = "PROVINCEID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "organization.PROVINCEID")
End With
End If
Catch ex As Exception
cboPROVINCE_TH.Text = Nothing
End Try
End Sub
Private Sub call_amphur()
ds.Tables.Clear()
Try
Dim sqldistrict As String = ""
sqldistrict = "SELECT * FROM district"
If cboPROVINCE_TH.ValueMember = "" Then
Exit Sub
Else
sqldistrict &= " where PROVINCEID = '" & CStr(cboPROVINCE_TH.SelectedValue) & "'"
sqldistrict &= " ORDER BY DISTRICTID"
da = New SqlDataAdapter(sqldistrict, Conn)
da.Fill(ds, "district")
If ds.Tables("district").Rows.Count <> 0 Then
With cboDISTRICT_TH
.DataSource = ds.Tables("district")
.DisplayMember = "DISTRICT_TH"
.ValueMember = "DISTRICTID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "organization.DISTRICTID")
End With
End If
End If
Catch ex As Exception
cboDISTRICT_TH.Text = Nothing
End Try
End Sub
Private Sub call_tambon()
ds.Tables.Clear()
Try
Dim sqltambon As String = ""
sqltambon = "SELECT * FROM tambon"
If cboDISTRICT_TH.ValueMember = "" Then
Exit Sub
Else
sqltambon &= " where DISTRICTID = '" & CStr(cboDISTRICT_TH.SelectedValue) & "'"
sqltambon &= " ORDER BY TAMBONID"
da = New SqlDataAdapter(sqltambon, Conn)
da.Fill(ds, "tambon")
If ds.Tables("tambon").Rows.Count <> 0 Then
With cboTAMBON_TH
.DataSource = ds.Tables("tambon")
.DisplayMember = "TAMBON_TH"
.ValueMember = "TAMBONID"
.DataBindings.Clear()
.DataBindings.Add("SelectedValue", ds, "organization.TAMBONID")
End With
End If
End If
Catch ex As Exception
cboTAMBON_TH.Text = Nothing
End Try
End Sub
Private Sub cboPROVINCE_TH_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboPROVINCE_TH.SelectedValueChanged
call_amphur()
End Sub
Private Sub cboDISTRICT_TH_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDISTRICT_TH.SelectedValueChanged
call_tambon()
End Sub
Date :
2012-11-15 21:45:25
By :
pisansri
No. 3
Guest
ชั้นเทพ...มาแล้วครับ....สุดยอดจริง....
Date :
2012-11-16 06:37:26
By :
nt
No. 4
Guest
SourceCode แบบนี้ใช้อธิบายเพื่อให้เข้าใจ OK 100%
SourceCode แบบนี้ใช้งานจริงไม่ได้ Cancel 100%