Solved

Searching for the beginning of a keyword - VB2010

Posted on 2011-03-14
4
357 Views
Last Modified: 2012-05-11
Hello,

I have this line of code that searches for any name that is similar to the keyword typed in my text box.
myDataView.RowFilter = String.Format("Name LIKE '%{0}%'", txtName.Text)

Open in new window


But if I type 'A', it's going to return all the names that have the letter A in it.  I want all the names that begin with the letter A.  How is this done?
0
Comment
Question by:--TripWire--
[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
  • 2
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 35131054
I'm guessing:

myDataView.RowFilter = String.Format("Name LIKE '%{0}'", txtName.Text)
0
 
LVL 17

Accepted Solution

by:
Daniel Reynolds earned 25 total points
ID: 35131059
change it to

:
 myDataView.RowFilter = String.Format("Name LIKE '{0}%'", txtName.Text)
0
 
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 25 total points
ID: 35131063
Sorry, the other way:
myDataView.RowFilter = String.Format("Name LIKE '{0}%'", txtName.Text)
0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 35131075
you will want the wildcard after your input value so {0}% will be the correct method.

if you do %{0} you will get anything ending in your input.
0

Featured Post

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 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