Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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