• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

VB.net and SQL Like function

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
Murray Brown
Asked:
Murray Brown
  • 2
2 Solutions
 
Atdhe NuhiuCommented:
0
 
plusone3055Commented:
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
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the help
0
 
Atdhe NuhiuCommented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now