?
Solved

VB.net SQL Check if name is within a string

Posted on 2014-09-11
11
Medium Priority
?
117 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:Murray Brown
[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
  • 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:Murray Brown
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:Murray Brown
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 2000 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:Murray Brown
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:Murray Brown
ID: 40317577
The whole point of my question is finding a string within a longer string
0
 

Author Closing Comment

by:Murray Brown
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:Murray Brown
ID: 40317694
Thanks again. Have a great day too
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

743 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