Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

A QUESTION ABOUT LIKE


Hello... again... :)

I was wondering if someone would be kind enough to answer why can't I use the operand Like (SQL) in Visual Basic Without having problems...

I am working on a PhoneBook Project in which I need to show the info kept in the database according to the first letter of a person's name. For example:

rs.Open("Select * From PhoneBook Where Name Like 'A*'")

I have many names that begin with A, but I do not get any matches...
Instead, I have to run a cycle and compare strings and check if the position that I got from an Instr function is 1 to finally know that I found a match...


Comments

  • jlegjleg Member Posts: 237
    :
    : Hello... again... :)
    :
    : I was wondering if someone would be kind enough to answer why can't I use the operand Like (SQL) in Visual Basic Without having problems...
    :
    : I am working on a PhoneBook Project in which I need to show the info kept in the database according to the first letter of a person's name. For example:
    :
    : rs.Open("Select * From PhoneBook Where Name Like 'A*'")
    :
    : I have many names that begin with A, but I do not get any matches...
    : Instead, I have to run a cycle and compare strings and check if the position that I got from an Instr function is 1 to finally know that I found a match...
    :
    :
    :
    I have used LIKE without any problems. I think its your asterisk thats the problem. I've used the % sign in my filters to product a filtered recordset. Try this

    rs.Open ("SELECT * FROM PhoneBook WHERE Name Like 'A%'") This should give you all records starting with A. What I have done in the past is to retrieve all records then filter by user input. This means you are not going back to the database are searching for a new recordset. eg:

    rs.Open ("Select * From PhoneBoook")

    rs.Filter = "Name Like 'A%'"

    You could write a function with filters at the users request. It works for me.

    Hope this helps

    John ;-)

Sign In or Register to comment.