• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

.net table adapter like clause question

I am trying to put a like statement in my strongly typed dataset table adapter, but don't know how to put the % sign in there.

Ths works when TestPlanCode and TestPlanOverview are exact strings, but I want to match the first part of the string. So 'a' would match 'abcd'

SELECT     TOP (@recordLimit) TestPlanGUID, TestPlanName, TestPlanOverview, TestPlanCode
FROM         vwTestPlansBrowse
WHERE     (TestPlanCode = @TestPlanCode) AND (TestPlanOverview like @TestPlanOverview)

This is what I am trying to do:

SELECT     TOP (@recordLimit) TestPlanGUID, TestPlanName, TestPlanOverview, TestPlanCode
FROM         vwTestPlansBrowse
WHERE     (TestPlanCode = @TestPlanCode) AND (TestPlanOverview like @TestPlanOverview + '%')

0
jackjohnson44
Asked:
jackjohnson44
  • 4
  • 2
1 Solution
 
DhaestCommented:
I think that it would be easier if you add the % to the string where you fill your parameter

parameter.value = "mystring" + "%"
0
 
jackjohnson44Author Commented:
can it be done the way I am doing it?
0
 
DhaestCommented:
I haven't tried it before, but I think that it must be possible to do it that way. Did you try it already ?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
DhaestCommented:
It can be that it just has to be
" ...  like @TestPlanOverview %)" or
" ...  like @TestPlanOverview + %)"

You'll have to test it and then you'll know soon enough :)
0
 
jackjohnson44Author Commented:
Neither worked, which is why I am asking the question.  I did something similar in my question with single quotes around it, and just tried both of your suggestions.  It will let me save the table adapter, but it complains that it can't parse the query text.
0
 
DhaestCommented:
Then I guess you'll have to do it like I told in my first post.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now