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
Solved

Help with partial string search using Substring

Posted on 2014-02-20
5
266 Views
Last Modified: 2014-02-20
Hi,


How do you modify the Substring below which searches for the first three characters in a field to search for part of the data in a data field,

For example if the field contains 9999-00-999-9999 Ho do I search only for 00, considering xyz '''00'".

Dim SearchCriteria as String = "Substring(SN, 1,3) IN ('" & xyz &"')

Thanks,

Victor
0
Comment
Question by:vcharles
  • 3
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39874177
Use the Like operator

Dim SearchCriteria as String = "SN LIKE '%" & xyz &"%'"
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 39874183
I think what you are saying is that if you have a field like

9999-00-999-9999

You want to search against the 6-7th characters instead of the 1-3rd characters, right?

Dim SearchCriteria as String = "Substring(SN, 6,2) IN ('" & xyz &"')
0
 

Author Comment

by:vcharles
ID: 39874395
Thank You for both answers, I will get back to you.

Victor
0
 

Author Comment

by:vcharles
ID: 39875104
Hi,

I was able to solve the issue withthe code below.

Dim SearchCriteria as String = "SN LIKE '%" & xyz &"%'"


Thanks,

Victor
0
 

Author Closing Comment

by:vcharles
ID: 39875105
Thank You.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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