[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 504
  • 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
 
Philip PinnellCommented:
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
 
Philip PinnellCommented:
Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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