Results 1 to 4 of 4

Thread: Problem with 'LIKE'

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274

    Post

    I have a problem using this line:
    Code:
    Dim cn as rdoConnection
    Dim rs as rdoResultset
    Dim SQL as string
    
    Cn.Connect = "Database=d:\code\tablas;" & _
              "Driver={MERANT 3.50 32-BIT FoxPro 3.0 Database (*.dbc)}"
    
    SQL = "SELECT * FROM contra WHERE centro LIKE '245*25530'"
    Set rs=cn.OpenResultset(SQL, rdOpenKeyset, rdConcurValues)
    And the rs.RowCount is equal to ZERO! And if I change the 'SQL = ...' line as follows:
    Code:
    SQL = "SELECT * FROM contra WHERE centro LIKE '2452533425530'"
    The rs.rowCount is equal to 8.

    Why the LIKE clause is not working with the comodin (*)?

    I'm using the RDO object and a MERANT ODBC dirvers (DirectData Connect ODBC 3.50 for Windows 9x-NT).

    I'll thank every help.

    Ulises

    [This message has been edited by Tonatiuh (edited 08-10-1999).]

  2. #2
    New Member
    Join Date
    May 1999
    Location
    Berlicum, The Netherlands
    Posts
    2

    Post

    Hi,

    I'm not completely sure, but this might be the solution:

    In general, when searching for a record in a field with a "string" data type you put the string being searched for between single quotation marks. Now however it's likely (for you're using numbers) that the field being searched doesn't contain data of the data type "string", but instead of a data type like "number" or "integer" or something like that. In general you aren't allowed to use the single quotationmarks then. Therefore I would suggest to remove the single quotation marks. (... LIKE 245*5530)This might however result in an unment calculation: 245*5530 = 1354850. That's surely not the purpose of your SQL. Therefore (assuming the field being searched is of a "string" data type) you perhaps have to change your field's data type into "string". Then there's probably no risk of computing 245 times 5530 resulting in 1354850.

    I hope I've helped you out now...
    (Sorry for my bad English, it's not my native language, you see)

  3. #3
    Lively Member
    Join Date
    Jul 1999
    Posts
    78

    Post

    Is this in Access or a different database?

    Try using % as it is typically equivalent to * in ANSI SQL.

  4. #4
    New Member
    Join Date
    Jun 1999
    Posts
    6

    Post

    Try this:
    Dim number1
    Dim number2

    number1 = 245
    number2 = 25530
    SQL= "Select * from contra where centro like '" & number1 & "*" & number2 & "';"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width