How can i search a string include ' example 'John

vb6 Turkey
  • 12 years ago

    hello,

    can you help me !

    How can i search a string include '    (  example =  'John  ) With ADODC .  

  • 12 years ago

    Hi, What exactly areyou trying to do? Could you provide a little more information?

    If you have a string, yuou can use the InStr function to discover whether it contains a certain substring/character.  eg.

    Dim myString As String
    myString = "'John"
    If InStr(1, "myString", "'") > 0 Then
         'The string is present
    End If

    Or you can remove/replace certain characters using the Replace Command:
    myString = Replace(myString, "'", "")

  • 12 years ago

    Thanks a lot guru , please reply me this

    'i want to find a string as 'John

    'when i find record in the following way

    Private Sub Command1_Click()

    ADO.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB\KST.mdb;Persist Security Info=False;"

    ADO.RecordSource = "SELECT * FROM tblSecurity WHERE [Password]= ''John'"

    ' the following error occour ' syntax error (missing operator)in query expression '[Password]="John"

    ADO.Refresh

    DG.Refresh

    End Sub

  • 12 years ago

    I think you need to escape the quotes, ie. use two single quotes instead of 1:

    ADO.RecordSource = "SELECT * FROM tblSecurity WHERE [Password]= '''John'"

  • 12 years ago

    As a side issue: I would advise against storing passwords as plain text, at the very least use a simple transposition algorithm to encrypt your string.  Heres a simple example, just encrypt the string before you store it in the db, and when you come to compare a password against it, just encrypt the string and compare the two encrypted strings:

    Function Encrypt(ByVal theString As String) As String
        Dim x, i, tmp As String
        For i = 1 To Len(theString)
            x = Mid(theString, i, 1)
            tmp = tmp & Chr(Asc(x) + 1)
        Next
        tmp = StrReverse(tmp)
        Encrypt = tmp
    End Function

    Private Sub Form_Load()
    Dim strRaw, strEncrypted As String
    strRaw = "John"
    strEncrypted = Encrypt(strRaw)
    Debug.Print strEncrypted
    End Sub

  • 12 years ago

     many thanks to you . now i got it .

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell