CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Switched from MS ACCESS to MS SQL

Print topic Send  topic

Author Message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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
View profile  Send private message
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.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.