16,556
社区成员
发帖
与我相关
我的任务
分享
Dim Conn As New OleDb.OleDbConnection
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Conn.ConnectionString = "provider=sqloledb;Data Source=S1;Initial Catalog=yz_jc;Persist Security Info=True;User ID=sa;Password=sa"
ds.Tables.Clear()
ds.Clear()
da = New OleDb.OleDbDataAdapter("select * from jcfl where area_parent=0 order by area_order", Conn)
da.Fill(ds, "jcfl")
ComboBox1.DataSource = ds.Tables(0)
ComboBox1.DisplayMember = "area_name"
ComboBox1.SelectedIndex = -1
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
ds.Tables.Clear()
ds.Clear()
da = New OleDb.OleDbDataAdapter("select * from jcfl where area_parent=" & ComboBox1.Text & " order by area_order", Conn)
da.Fill(ds, "jcfl")
ComboBox2.DataSource = ds.Tables(0)
ComboBox2.DisplayMember = "area_name"
End Sub