v$ = "%" + InputRequester("", "Enter Nutritiongroup:", "") + "%"
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup Like '" +v$+ "' " ) , This one is good
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup = '" +v$+ "' ") , This one is NOT good, I get none record.
Please help !
I Need some database coding help
Re: I Need some database coding help
Hi,
= means: exactly identical as
But you have % as head and tail.
It can not fit exactly.
Bernd
= means: exactly identical as
But you have % as head and tail.
It can not fit exactly.
Bernd
Re: I Need some database coding help
don't include % inside v$
Norm.
Code: Select all
v$ = InputRequester("", "Enter Nutritiongroup:", "")
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup Like '%" +v$+ "%' " ) ; % here
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup = '" +v$+ "' ") ; % NOT here
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Re: I Need some database coding help
Thank you for good advice.




Re: I Need some database coding help
If you want to be more secure (avoid code injection)
and let user input string with: " and/or '
use labels (with SetDatabaseString etc)
So long Chr(34) and ' "+ +" ' to make SQL strings
Thank's Falsam (french forum) for this reminder of PB possibilities.

and let user input string with: " and/or '
use labels (with SetDatabaseString etc)
Code: Select all
; Normal query
v$ = InputRequester("", "Enter Nutritiongroup:", "")
SetDatabaseString(1, 0, v$)
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup = ? ")
; Like query
v$ = "%" + InputRequester("", "Enter Nutritiongroup:", "") + "%"
SetDatabaseString(1, 0, v$)
DatabaseQuery(1, "SELECT * FROM Food where Nutritiongroup Like ? ")


Thank's Falsam (french forum) for this reminder of PB possibilities.
