-1
如何过滤我的组合框显示如果我的Label.text ="ad"
,我想只显示那些在数据库上有“ad”不显示所有。 但错误无效参数=值'0'对于SelectedIndex参数名称无效:Selectedindex“出现”。错误无效参数='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
你确定你的查询实际上返回的结果吗?如果cmbsection控件有0个项目,则不能将您的SelectedIndex设置为第一个项目。 – JDB
这应该是什么适当的代码。 – user2715202
我还会补充说你的应用程序有一个教科书[SQL注入攻击](http://msdn.microsoft.com/en-us/library/ff648339.aspx)漏洞。 – JDB