Solved

ASP.net DataAdapter query not working as expected

Posted on 2011-02-13
2
364 Views
Last Modified: 2012-05-11
Hi. have an ASP.net project with a three column SQL database containing school sporting data.
I created a table adapter as shown in the image then used the code shown below to populate a GridView with all records that had "Cricket" or "Rugby" as part of the information in the "Detail" column.
The problem is that the data is loaded only for records that contain only the word "Cricket" or "Rugby" - it doesn't work if any other data is included eg "Cricket U15" - I thought that this is how "LIKE" works
Image of table adapter
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim DS1Adapter As New DataSet1TableAdapters.Table1TableAdapter
        Dim blnRugby, blnCricket, blnTennis, blnSwimming, blnHockey As Boolean
        Dim SportsText1, SportsText2 As String
        Dim intAgeGroup As String
        'GridView1.DataSource =
        'productsAdapter.GetProductsByCategoryID(1)
        intAgeGroup = Me.DropDownList1.SelectedValue

        'GridView1.DataSource =
        'DS1Adapter.GetProductsByCategoryID(intCategoryID)
        GridView1.DataSource =
        DS1Adapter.GetDataBy("Rugby", "Cricket")

        GridView1.DataBind()
    End Sub

Open in new window

0
Comment
Question by:murbro
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34884118
LIKE will need % to work ...

WHERE colDetail like @Parameter1 + '%'
   OR colDetail like @Parameter2 + '%'

Open in new window

0
 

Author Closing Comment

by:murbro
ID: 34884156
Thanks a ton. Worked straigh away - just in time for my early morning meeting. Much appreciated.
Murray
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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