Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement works in Access and not in VB 2

Status
Not open for further replies.

Denaeghel

Programmer
Apr 23, 2001
61
BE
This SQL-statement works in ACCESS 2000 and not in VB 6.0? What's wrong with it?

txtZoek.Text = "*" & txtZoek.Text & "*"

With rsZoekAuteurs
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open "Select Bestanden.Bestandsnummer, & _
Bestanden.Bestandsnaam, Bestanden.Soort, & _
Bestanden.Omschrijving, Bestanden.Auteurs, & _
Bestanden.[Datum Archivering] from Bestanden & _
where Bestanden.Auteurs like '" & txtZoek.Text & "'"
End With
Set Adodc1.Recordset = rsZoekAuteurs
 
what sort of doesnt work. what happens Peter Meachem
peter@accuflight.com
 
A datagrid is connected to adodc1 and it doesn't show us the result. The strange thing is that when we replace "like" by "=" in the SQL-statement the thing works!?!
 
instead of

'" & txtZoek.Text & "'"

use

'" & txtZoek.Text & "*'"

or

'*" & txtZoek.Text & "'"

or even

'*" & txtZoek.Text & "*'"


Peter Meachem
peter@accuflight.com
 
Sorry, it doesn't work. I just mistyped my string. It is the same result.
 
Have you tried using the % and _ SQL wildcards?
 
.Open "Select Bestanden.Bestandsnummer, & _
Bestanden.Bestandsnaam, Bestanden.Soort, & _
Bestanden.Omschrijving, Bestanden.Auteurs, & _
Bestanden.[Datum Archivering] from Bestanden & _
where Bestanden.Auteurs like '%" & txtZoek.Text & "%'"

Try it this way and see if it will work. I think it should.
Every day above ground is a GOOD DAY!!!
 
i think you should write it this way....

SQL = "Select Bestanden.Bestandsnummer, " & _
"Bestanden.Bestandsnaam, Bestanden.Soort, " & _
"Bestanden.Omschrijving, Bestanden.Auteurs, " & _
"Bestanden.[Datum Archivering] from Bestanden " & _
"where Bestanden.Auteurs like '" & txtZoek.Text & "'"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top