Select statement
-
What is wrong with my statement? Dim mySelectQuery As String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'" Rdate is a value from the database. I get this error : Cast from string "SELECT * FROM table where recv" to type 'Long' is not valid. Thank you
-
What is wrong with my statement? Dim mySelectQuery As String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'" Rdate is a value from the database. I get this error : Cast from string "SELECT * FROM table where recv" to type 'Long' is not valid. Thank you
All 3 expressions for between must be the same datatype. If Rdate is from Type Date you must convert FromData.value and ToDate.value to a Date. This conversion depends on the database system. Look there for more information. If you use SQLServer see in Transact-SQL-Help for command 'CAST', 'CONVERT','BETWEEN' and 'DATETIME'. Regards Stephan
\\\\\\|/// \\\\ - - // ( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| www.stephan-pilz.de |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_) -
What is wrong with my statement? Dim mySelectQuery As String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'" Rdate is a value from the database. I get this error : Cast from string "SELECT * FROM table where recv" to type 'Long' is not valid. Thank you
Rigard wrote:
String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'"
Try this (Assuming RDate is of DateTime type): "SELECT * FROM table where Rdate between #" & FromDate.Value & "#" And "#" & ToDate.Value & "#"
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
-
What is wrong with my statement? Dim mySelectQuery As String = "SELECT * FROM table where Rdate between '" & FromDate.Value & "'" And "'" & ToDate.Value & "'" Rdate is a value from the database. I get this error : Cast from string "SELECT * FROM table where recv" to type 'Long' is not valid. Thank you
Rigard wrote:
What is wrong with my statement?
You inject values into the SQL, which is a security risk and causes other problems. Use parameterised queries instead of injecting values.
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog