Solved

VB.net SQL Check if name is within a string

Posted on 2014-09-11
11
111 Views
Last Modified: 2014-09-11
Hi

I have VB.nrt code where I use the following SQL to check if a child's name is in a certain string. There is a child with the name "Nahil" but the following returns no match
Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('ABSA BANK Nahil LaherNMA',[Child Name]) > 0
0
Comment
Question by:murbro
  • 6
  • 5
11 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317423
my initial though is there should be a space somewhere for example
Nahil LaherNMA

should be
Nahil Laher NMA
0
 

Author Comment

by:murbro
ID: 40317444
Hi. That makes no difference unfortunately
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317452
have you run it against another name where it does return a specific  result and if so please post that
 code
so we can dig deeper  :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:murbro
ID: 40317485
I used the following. There are ten children with the name "Jayden". Nothing came up

Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('I think Jayden was here',[Child Name]) > 0
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 500 total points
ID: 40317507
test this out

Select  [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] LIKE '%Jayden%'

if that works  and brings back the 10

try
Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0
 

Author Comment

by:murbro
ID: 40317547
I tried Select Distinct [CustomerID], [BANK_REF] From [CHILDREN] Where [Child Name] = 'Jayden' and it brought back the ten
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317569
Then use

Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0
 

Author Comment

by:murbro
ID: 40317577
The whole point of my question is finding a string within a longer string
0
 

Author Closing Comment

by:murbro
ID: 40317592
This LIKE function actually does the job well. Sorry about the confusion
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317620
I thought it would.. No worries
Have a great day :)
0
 

Author Comment

by:murbro
ID: 40317694
Thanks again. Have a great day too
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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 antispam), the admini…

749 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