View Full Version : Problem in Select from DB !!!
augean
05-31-2003, 04:39 PM
Hi
I have problem when I want to select record from DB
I use this sql statement :
Set RS = MyConn.Execute ("SELECT * FROM tblUsers WHERE UID = '" & nID & "'")
now if "nID" is a Text in my DB it works good , but if it is a number it doesnt .
How can I make it works ??
I'll appreciate any help or any idea .
Thank you
~Augean
augean
05-31-2003, 04:41 PM
Hi again ,
let me correct some part of my question :
if the field that I put in "WHERE" statement , is a TEXT it works but not when it is NUMBER.
TNX
~Augean
Frank
05-31-2003, 05:10 PM
If you are looking to read a number from the database, then you don't need the apostrophes. Your original SELECT clause:
Set RS = MyConn.Execute ("SELECT * FROM tblUsers WHERE UID = '" & nID & "'")
will work fine for text values. If you are reading a number try this:
Set RS = MyConn.Execute ("SELECT * FROM tblUsers WHERE UID = " & nID)
HTH!
Frank
augean
05-31-2003, 05:18 PM
Thank you Frank ,
it works great
~Augean
nissim
06-01-2003, 10:58 AM
SELECT * FROM tblUsers WHERE UID = " & nID
fyrye
06-01-2003, 12:59 PM
depending on the database field properties IE (Field is text or field is number) states what method you need to use.
similar to this statment in an if clause
FileSize = request("Size")
if filesize < 0 then
do something
end if
This for some reason returns an error regaurdless if the value is a number or not.
my SQL statements look like this
Text:
mySQL = "Select * from tbl where User = ' " & Text & " ' "
Number:
mySQL = "Select * from tbl where ID = " & Number
Both:
mySQL = "Select * From tbl where ID = " & Number & " AND User = ' " & Text & " ' "
Set RS = MyConn.Execute (mySQL)
spaced them out so you can see the actual difference in quotes.
augean
06-01-2003, 02:02 PM
TNX for all your helps and information
it works great now
Thank you again
~Augean
vBulletin v3.0.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.