主题:请求帮助,急!!
Public Class Form1
Inherits System.Windows.Forms.Form
Dim dt As DataTable
Dim result As DataRow
Dim ctr As Integer
Dim custid As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim resultarray() As DataRow
oledapter.Fill(Daset1)
dt = Daset1.Tables("customers")
resultarray = dt.Select()
For ctr = 0 To (resultarray.Length - 1)
lsbID.Items.Add(resultarray(ctr)("CustomerID").ToString)
Next
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
custid = lsbID.SelectedItem()
result = dt.Rows.Find(custid)
Dim st As DataColumn
txtname.Text = dt.Columns(1).ToString
txtphone.Text = dt.Columns(2).ToString
txtaddress.Text = dt.Columns(3).ToString
End Sub
我这个程序是连接数据库,在列表框里显示CustomerID,然后在列表中点击任何一个CUSTOMERID在那几个文本框里显示CustomerID所对应的姓名、电话和地址
Inherits System.Windows.Forms.Form
Dim dt As DataTable
Dim result As DataRow
Dim ctr As Integer
Dim custid As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim resultarray() As DataRow
oledapter.Fill(Daset1)
dt = Daset1.Tables("customers")
resultarray = dt.Select()
For ctr = 0 To (resultarray.Length - 1)
lsbID.Items.Add(resultarray(ctr)("CustomerID").ToString)
Next
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
custid = lsbID.SelectedItem()
result = dt.Rows.Find(custid)
Dim st As DataColumn
txtname.Text = dt.Columns(1).ToString
txtphone.Text = dt.Columns(2).ToString
txtaddress.Text = dt.Columns(3).ToString
End Sub
我这个程序是连接数据库,在列表框里显示CustomerID,然后在列表中点击任何一个CUSTOMERID在那几个文本框里显示CustomerID所对应的姓名、电话和地址