Answered by:
Unable to query with parameter.

Question
-
User336673788 posted
Hi guys,
My have a column SerialNumber with Text as the datatype.
from my app, i'm able to insert record:
record 1 the serial#: 123456
record 2 the serial#: hellowithin my app, i have a search for serial number: when i search for 123456, the record is found, but when i search for hello, it does not return anything. Both records are in the database.
Here's the Query:
cmd.commandtext = SELECT * FROM TOYS WHERE SERIALNUMBER = ?;
OleDbParameter param = new OleDbParameter("@SerialNumber", OleDbType.VarChar, 100);
param.value = argSerialNumber;
cmd.parameters.add(param);
return (string)executeScalar();again, searching for 123456 works, but not the hello. any input is appreciated.
Monday, April 4, 2011 3:28 PM
Answers
-
User336673788 posted
:p
okay, my bad. i have a custom function to validate the serialnumber "isNumeric". in the code ... hahaha, thank you. that's what you get for looking at the screen too long.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 4, 2011 5:03 PM
All replies
-
User-2010311731 posted
Not sure why this would be a problem. Did you try making sure both "hello" strings were trimmed and lower-case?
Matt
Monday, April 4, 2011 3:41 PM -
User336673788 posted
its all lower case. i copy and paste the string ... i know, it should work since it's text (string). how odd.
Monday, April 4, 2011 4:42 PM -
User-2010311731 posted
cmd.commandtext = SELECT * FROM TOYS WHERE SERIALNUMBER = ?;
Possibly try putting double-quotes around the ?...
cmd.commandtext = SELECT * FROM TOYS WHERE SERIALNUMBER = "?";
Matt
Monday, April 4, 2011 4:57 PM -
User336673788 posted
:p
okay, my bad. i have a custom function to validate the serialnumber "isNumeric". in the code ... hahaha, thank you. that's what you get for looking at the screen too long.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 4, 2011 5:03 PM