当我更改具有另一个组合框的组合框索引时,我发现此错误
Private Sub cmbcollege_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbcollege.SelectedIndexChanged
Dim sql As String = "select major ,code from major_code where code in (select major from college_major where college = " & cmbcollege.SelectedValue & ")"
Dim dt As New SqlDataAdapter(sql, CON)
Dim ds As New DataSet
Try
CON.Open()
dt.Fill(ds)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
CON.Close()
End Try
Dim c As Integer = ds.Tables(0).Rows.Count - 1
For i As Integer = 0 To c
cmbMajor.DisplayMember = "major"
cmbMajor.ValueMember = "code"
cmbMajor.DataSource = ds.Tables(0)
Next
End Sub