Binding results of query to repeater control

dprasadAsked:
Who is Participating?
 
amyhxuConnect With a Mentor Commented:
The problem is with your query strings :
"Select * From maintable where color=" & color.SelectedItem.Text
"Select * From maintable where category=" & category.SelectedItem.Text

In SQL you use "Select * From maintable where color = 'Red'" for string comparison.

So modify your query strings to:
"Select * From maintable where color = '" & color.SelectedItem.Text.Trim & "'"
"Select * From maintable where category = '" & category.SelectedItem.Text.Trim & "'"

Or use parameters in the query:
"Select * From maintable where color = @color"
"Select * From maintable where category = @category"
and you need the code to add parameters to sqlcommand.
 
By the way, if you use integers to represent color and category, your queries become:
"Select * From maintable where color=" & color.SelectedItem.Value
"Select * From maintable where category=" & category.SelectedItem.Value

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.