Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.net DataAdapter query not working as expected

Posted on 2011-02-13
2
Medium Priority
?
369 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:Murray Brown
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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:Murray Brown
ID: 34884156
Thanks a ton. Worked straigh away - just in time for my early morning meeting. Much appreciated.
Murray
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

782 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