Joe
|
| Posted: 07/16/2004, 8:51 AM |
|
I used the following code to get the login_count, Last_login update, now it does not work, i do not get any error, it just not update either one, I pretty sure it is because i switched to MS SQL, but i have no clue why, any help would be great.
Dim Conn
Set Conn = New clsDBConnection1
Conn.Open
Response.write "update Information set last_login=DateAdd('h',3, NOW()), Login_Count = Login_Count+1 where UsrID=" & CCGetUserID()
Dim Res
Res = CCExecSQL ("update Information set last_login=DateAdd('h',3, NOW()), Login_Count = Login_Count+1 where UsrID=" & CCGetUserID(), Conn, true)
If not isEmpty(Res) then
Login.Errors.addError("SQL error")
End if
Conn.Close
Set Conn = Nothing
Thanks
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 07/16/2004, 12:51 PM |
|
You are using the "DateAdd" and "Now" functions in your SQL and I suspect that MS SQL doesn't support one or the other, or may support them differently.
Try this link for your research: http://www.google.com/search?q=%22SQL+server%22+functions+DateAdd
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
dataobjx
Posts: 181
|
| Posted: 07/19/2004, 5:14 AM |
|
Your SQL is not right. Since you are mixing vbScript with SQL when trying to construct your SQL string.
Try this... Also, when you're passing a date/time you need to place appostrophes on either side of the value. e.g., 'date_time' ;
Dim SQL
Dim lngLoginCount
lngLoginCount = CCDLookup("Login_Count", "Information", "UsrID=" & CCToSQL(CCGetUserID, "Integer"), DBIntranet)
lngLoginCount = lngLoginCount + 1
SQL = "update Information set last_login='" & DateAdd('h',3, NOW()) & "', Login_Count = " & lngLoginCount & " where UsrID=" & CCGetUserID()
'Debug: View SQL
'Response.write SQL & "<BR>"
Res = CCExecSQL(SQL)
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
Joe
|
| Posted: 07/23/2004, 11:31 AM |
|
I still get an Error,
Microsoft VBScript compilation error '800a03ea'
Syntax error
/FreightManagement/Login_events.asp, line 74
SQL = "update Information set last_login='" & DateAdd('h',3, NOW()) & "', Login_Count = " & lngLoginCount & " where UsrID=" & CCGetUserID()
|
|
|
 |
dataobjx
Posts: 181
|
| Posted: 07/23/2004, 5:13 PM |
|
Joe,
You're using apostrophe's within the dateAdd function - should be using " single quotes around the "h".
Here's how it should look.
Dim dteDate
dteDate = DateAdd("h",3, NOW())
SQL = "update Information set last_login='" & dteDate & "', Login_Count = " & lngLoginCount & " where UsrID=" & CCGetUserID()
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
dataobjx
Posts: 181
|
| Posted: 07/23/2004, 5:15 PM |
|
Joe,
I aplolgise for not seeing this sooner. I had simply grabbed your code from the initial post and didn't notice the apostrophes around the "h".
Sorry for any frustration that may have resulted.
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
Joe Miller
|
| Posted: 07/26/2004, 1:57 PM |
|
dataobjx, Thanks for all you help, I got my original code to work by taking out the apostrophes.login='" & DateAdd('h',3, NOW()) & "', Login_Count = and using this one instead login='" & DateAdd(hh,3, NOW()) & "', Login_Count = I had hours "h" instead of hh. so i changed that and now my code iwrking perfect again. i do thank you for your help, it got me thinking, Thanks have a great day.
|
|
|
 |
|