Binding results of query to repeater control

Posted on 2005-05-09
Last Modified: 2010-04-23
Question by:dprasad
    1 Comment
    LVL 14

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now