ADO Query into Access 97 Database using VB6 
Author Message
 ADO Query into Access 97 Database using VB6

I am trying to make an ADO query into an MS Access 97 database using VB6

szSeek is the searchstring coming from a textbox in a form

    If szSeek = "" Then
        'If the is not searchstring give me all records in the database
        sSQL = "select
KundeID,FirstName,LastName,Address,Firm,HomePhone,WorkPhone,AltPhone,Notes
from Kunde Order by KundeID"
    Else
        'Search for records based on the szSeek variable
        sSQL = "select
KundeID,FirstName,LastName,Address,Firm,HomePhone,WorkPhone,AltPhone,Notes
from Kunde _
        where Lastname  = '" & szSeek & "' Order by LastName "
    End If

Say that I want to search for all the records with the lastname  = Jensen
the query works just fine 2 records comes up.....!!
the problem come when I just enter 'Jen' in the szSeek variable, it finds no
records..!!

It is possible to do a search using only partial searchstrings with some
sort of wildcards .??

Rico R. Jensen



Tue, 24 Jul 2001 03:00:00 GMT  
 ADO Query into Access 97 Database using VB6
Try this:

 where Lastname  LIKE  "'%" & szSeek  & "%'" Order by LastName "



Tue, 24 Jul 2001 03:00:00 GMT  
 ADO Query into Access 97 Database using VB6
Sorry

The "%" is for SQL Server For MS Access use "*" instead.

Quote:

>Try this:

> where Lastname  LIKE  "'%" & szSeek  & "%'" Order by LastName "



Tue, 24 Jul 2001 03:00:00 GMT  
 ADO Query into Access 97 Database using VB6
I think using "%" is correct, even if it is MS Access.  This has to do with
the Provider you use to make a connection using ADO.
I tried using "*" and "?" for wildcards and it didn't work.  Then I tried
"%" and "_" and it worked fine.
I was using ADO 2.0 with the Microsoft.Jet.OLEDB.3.51 provider


Tue, 24 Jul 2001 03:00:00 GMT  
 ADO Query into Access 97 Database using VB6

Many, many thanks for the advise, it works like a charm..!!!!

Exatly the kind of solution that I wanted..!!

Regards..!!
Rico

Quote:

>Try this:

> where Lastname  LIKE  "'%" & szSeek  & "%'" Order by LastName "



Wed, 25 Jul 2001 03:00:00 GMT  
 ADO Query into Access 97 Database using VB6


Quote:
>from Kunde _
>        where Lastname  = '" & szSeek & "' Order by LastName "

Try the wildcard '*' in combination with "like"

         where Lastname  like '" & szSeek & "*' Order by LastName "

Axel



Sat, 28 Jul 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ADO Query into Access 97 Database using VB6

2. VB6/ADO/Access 97 Unsuccessful Query

3. Connecting to Access 97 Database using ADO with OLE DB Driver

4. Connecting to Access 97 Database using ADO with OLE DB Driver

5. Accessing Usernames in Ms Access 97 Using ADO

6. Can't update sorted access query from vb6 using ado

7. Using VBA to Convert Access 2000 database to Access 97

8. Accessing a password protected Access 97 database using the Jet Engine

9. VB6 - DAO - Access 97 - Getting status at real-time when performing a query

10. VB6 running and Access 97 query

11. Store Query in Access Database Using ADO

12. Calling a query from an Access database using ADO

 

 
Powered by phpBB® Forum Software