Solved

ASP.net DataAdapter query not working as expected

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

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 …
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…
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 …

679 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