我使用 vb.net。有一个小问题。我从组合框中选择哪个学生 ID,然后我需要另一个文本框根据所选 ID 更改数据,但问题是值成员只读取一个值成员。
这是我的代码:
Dim dastudent As New Odbc.OdbcDataAdapter("SELECT * from student ", myconnection)
Dim dsstudent As New DataSet
'Load data about student id into the combo box
dastudent.Fill(dsstudent, "student")
cboID.DataSource = dsstudent.Tables("student")
cboID.DisplayMember = "Student_Id"
cboID.ValueMember = "Student_Name"
cboID.ValueMember = "Student_Tel_No"
cboID.ValueMember = "Student_Address"
cboID.ValueMember = "Mentor_Name"
End Sub
Private Sub cboID_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboID.SelectedIndexChanged
Dim dastudent As New Odbc.OdbcDataAdapter("SELECT * from student WHERE (Student_Id= '" & cboID.Text & "')", myconnection)
txtName.Text = cboID.SelectedValue.ToString()
txtTelNo.Text = cboID.SelectedValue.ToString()
lboAddress.Text = cboID.SelectedValue.ToString()
txtMentor.Text = cboID.SelectedValue.ToString()
End Sub
如何根据数据库中的索引分配值成员。预先感谢。