Solved

ASP.net DataAdapter query not working as expected

Posted on 2011-02-13
2
361 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 142

Accepted Solution

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

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

Open in new window

0
 

Author Closing Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

10 Experts available now in Live!

Get 1:1 Help Now