Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqldv
Starting Member
2 Posts |
Posted - 2006-05-24 : 21:25:25
|
| I'm newbie to VB and Sql Server. I would like to ask as what wrong to the query statement below : Dim qry As String = "SELECT PASSWORD FROM S_USER WHERE USER_ID='" & UserId & "' AND PASSWORD_EXPIRE_DATE > = '" & TodayDate & "'"It prompt me ExeceptCOM error in VBToday Date format is date, however in the table password_expire_date is datetime. So, it's concern about the date format?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-24 : 21:28:59
|
try to format the TodayDate to YYYYMMDD KH |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-25 : 01:24:03
|
| if TodayDate is the currentdate then you can use GetDate()Somthing like this Dim qry As String = "SELECT PASSWORD FROM S_USER WHERE USER_ID='" & UserId & "' AND PASSWORD_EXPIRE_DATE > = GetDate()"If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-25 : 04:07:07
|
| Use Command object and parameters instead of using concatenated sql statement. The date is not in proper format. what is the value of TodayDate?MadhivananFailing to plan is Planning to fail |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-05-25 : 08:46:19
|
| Its better to avoid what u r doing and use command object's parameters to pass data (for the system to be more secured)And, if u want to find the error :write the following after assigning the value to qrydebug.print qry go to immediate window and get the SQL Query in that - Copy & paste on Query Analyzer - Execute it.U'll c the error.Srinika |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-05-25 : 09:38:48
|
quote: Originally posted by sqldv I'm newbie to VB and Sql Server. I would like to ask as what wrong to the query statement below : Dim qry As String = "SELECT PASSWORD FROM S_USER WHERE USER_ID='" & UserId & "' AND PASSWORD_EXPIRE_DATE > = '" & TodayDate & "'"It prompt me ExeceptCOM error in VBToday Date format is date, however in the table password_expire_date is datetime. So, it's concern about the date format?Thanks
If you are a newbie, now is a good time to learn rule #1 when working with databases from a client: NEVER do what you are doing. Never concatenate and build SQL strings like this. Learn to use parameters, as it has already been suggested. If you take the time to really learn and understand this now, you will almost instantly be smarter than 75% of the database programmers out there and you'll be off to a great start!- Jeff |
 |
|
|
|
|
|