Solved

VB.net and SQL Like function

Posted on 2013-07-02
4
493 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 250 total points
ID: 39293236
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 250 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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