Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net and SQL Like function

Posted on 2013-07-02
4
Medium Priority
?
500 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
  • 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

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!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline

773 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