Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.net and SQL Like function

Posted on 2013-07-02
4
Medium Priority
?
496 Views
Last Modified: 2013-07-03
Hi

I need to compare two string variables in my VB.net code. Is it possible to simulate the SQL "Like" function in VB.net?
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
  • 2
4 Comments
 
LVL 13

Assisted Solution

by:Philip Pinnell
Philip Pinnell earned 1000 total points
ID: 39293236
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 1000 total points
ID: 39293289
Dim lastname As String
        Dim searchcritera As String
        Dim searchstring As String = ""
        Dim formula As String

        lastname = txtlastname.Text


        If cboCriteria.SelectedIndex = 0 Then      --starts with
            searchString = lastname & "*"
        ElseIf cboCriteria.SelectedIndex = 1 Then   --Contains
            searchString = "*" & lastname & "*"

        End If


        formula = "{customers.last name} like """ & searchstring & """"


        reportToView.DataDefinition.RecordSelectionFormula = Formula

        Me.CrystalReportViewer1.ReportSource = reportToView
0
 

Author Closing Comment

by:Murray Brown
ID: 39294078
Thanks for the help
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 39295823
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 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