Solved

ASP.net DataAdapter query not working as expected

Posted on 2011-02-13
2
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding SQL Server Browser in after install is complete 8 59
Help with SQL pivot 11 50
ASP.NET sqlds databinding error cascading dropdownlists ? 1 19
SQL query 45 41
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…

752 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