Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to filter using CheckedListBox, and so far it always gives me the "No Value Given" error when I have these codes:

For item As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
           Dim sql = "select * from Status where Stat= " & CheckedListBox1.CheckedItems(item).ToString() & ""
           Dim dt As DataTable
           Dim ds As New DataSet
           cnn = New OleDbConnection(connectionString)

           Try
               cnn.Open()
               adptr = New OleDbDataAdapter(sql, cnn)
               adptr.Fill(ds)
               adptr.Dispose()
               cnn.Close()

               dt = ds.Tables(0)
               Form5.DataGridView1.DataSource = dt

           Catch ex As Exception
               MsgBox(ex.ToString)
           End Try
           Form5.DataGridView1.Visible = True
       Next


I'm pretty sure my Access tables are named correctly..
Posted

You probably need to wrap single quotes around the variable that you are substituting in:

Dim sql = "select * from Status where Stat= '" & CheckedListBox1.CheckedItems(item).ToString() & "'"
 
Share this answer
 
It works! Thank you very much :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900