得到错误无效的参数=值'0'对于SelectedIndex'参数名称无效:Selectedindex

时间:2013-10-01 12:47:53

标签: .net vb.net

如果我Label.text ="ad",我如何过滤组合框显示,我只想显示那些在数据库上有“广告”且不应全部显示的人。 但是错误无效的参数=值'0'对于SelectedIndex'参数名称无效:Selectedindex“出现”。

Private Sub FillCombo()
   Try
       conn = New OleDbConnection(Get_Constring)

       Dim sSQL As String = ("SELECT subject FROM student where subject like'" & Label25.Text & "%' ")
       Dim da As New OleDbDataAdapter(sSQL, conn)

       Dim ds As New DataSet
       da.Fill(ds)

       cmbsection.ValueMember = "subject"
       cmbsection.DataSource = ds.Tables(0)
       cmbsection.SelectedIndex = 0

   Catch ex As Exception
       MsgBox("ERROR : " & ex.Message.ToString)
   End Try
End Sub

1 个答案:

答案 0 :(得分:0)

Dim sSQL As String = ("SELECT subject FROM student where **username** like'" & Label25.Text & "%' ")

solved :)