Solved

VB.net SQL Check if name is within a string

Posted on 2014-09-11
11
115 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
[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: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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 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