PDA

View Full Version : sql statement - Data type mismatch in criteria expression


gibby
12-02-2002, 06:38 PM
ive coded my site in jscript asp. Ive got a sql statement that should have no problems the statement that ive got is.....

oRecordSet = oConnection.Execute( "SELECT Title FROM News WHERE newsID =\"" + Nid + "\"")

I get error above when I try and run the script. If I exchange the variable Nid for a number the statement will work. The variable Nid stands for News ID and contains a numeric value. I know it contains a numeric value because I used it in a sum and it came out with the correct answer. If it was a string it would have added it on to the end of the string. And I also tried it with the IsFinite method and it didn’t return a false value.
I used exactly the same syntax in all my other sql statements and I have'nt had a problem with any of those so I’m a bit puzzled. Any help would be appreciated. Thanks

whammy
12-03-2002, 12:43 AM
I usually code in VBScript with ASP, but I do use JavaScript sometimes, and a lot client-side of course... try this perhaps?:

oRecordSet = oConnection.Execute( "SELECT Title FROM News WHERE newsID = " + Nid)

gibby
12-04-2002, 07:45 PM
yeah thanks that worked a treat, much appreciated.