CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 ASP Help Please?

Print topic Send  topic

Author Message
lneisius
Posted: 04/04/2003, 10:42 AM

I modified the CCS login function to update a couple of fields when a user logs in and can't get the now() function to work. I tried to set the projects date type to every date type available. and set the data base type to all available. The now() will not place anything in the dbase, Date() on the other hand will change the database information but with the wrong information. Here is the code:

Function CCLoginUser(Login, Password)
Dim Result
Dim SQL
Dim RecordSet
Dim Connection

Set Connection = New clsDBPortal
Connection.Open
SQL = "SELECT MemberID, FirstName, LastName, Visits, LastLogin, ThemeID, MemberGroupID, MemberStatusID FROM Members WHERE MemberStatusID >2 And MemberLogin='" & Replace(Login, "'", "''") & "' AND MemberPassword='" & Replace(Password, "'", "''") & "'"
Set RecordSet = Connection.Execute(SQL)
Result = NOT RecordSet.EOF
If Result Then
Response.Cookies ("MemberID") = RecordSet("MemberID")
Response.Cookies ("MemberLogin") = Login
Response.Cookies ("MemberPassword") = Password
Response.Cookies ("MemberName") = RecordSet("FirstName") & " " & RecordSet("LastName")
Response.Cookies ("MemberGroupID") = RecordSet("MemberGroupID")
Response.Cookies ("MemberVisits") = RecordSet("Visits") + 1
Response.Cookies ("MemberLastLogin") = RecordSet("LastLogin")
Response.Cookies ("Theme") = CCDLookUp("Theme", "Themes", "ThemeID=" & RecordSet("ThemeID"), Connection)

Response.Cookies ("MemberID").Expires = Date + 120
Response.Cookies ("MemberLogin").Expires = Date + 120
Response.Cookies ("MemberPassword").Expires = Date + 120
Response.Cookies ("MemberName").Expires = Date + 120
Response.Cookies ("MemberGroupID").Expires = Date + 120
Response.Cookies ("MemberVisits").Expires = Date + 120
Response.Cookies ("MemberLastLogin").Expires = Date + 120
Response.Cookies ("Theme").Expires = Date + 120

Session("MemberID") = Request.Cookies ("MemberID")
Session("MemberLogin") = Request.Cookies ("MemberLogin")
Session("MemberPassword") = Request.Cookies ("MemberPassword")
Session("MemberName") = Request.Cookies ("MemberName")
Session("MemberGroupID") = Request.Cookies ("MemberGroupID")
Session("MemberVisits") = Request.Cookies ("MemberVisits")
Session("MemberLastLogin") = Request.Cookies ("MemberLastLogin")
Session("Theme") = Request.Cookies ("Theme")

End If
CCLoginUser = Result
RecordSet.Close
Set RecordSet = Nothing
SQL = "UPDATE Members SET Visits=" & Session("MemberVisits") & ", LastLogin=" & Now() & "WHERE MemberID=" & Session("MemberID")
Connection.Execute(SQL)
' SQL = "INSERT INTO Log(MemberID, Date) VALUES(" & CCGetUserID & "," & Now() & ")"
' Connection.Execute(SQL)
Connection.Close
Set Connection = Nothing
End Function

You will also notice that I started a running log of visitors but have it remarked out at this time because of the same issue with the Now() function I haven't even tested this part yet. Any help Please? Also if someone has a better way of doing all this I'm all ears!
GreggB
Posted: 04/04/2003, 11:15 AM

What database are you using? MS SQL, Access etc...

GreggB
lneisius
Posted: 04/04/2003, 4:06 PM

MS Access 2000
I have tested with a textbox and a default value of now() and it post the correct data. Just don't get it!
Bill Noble
Posted: 04/05/2003, 3:08 AM

Hi lneisius

If you run this:

<html>
<body>

<%
response.write(FormatDateTime(date(),vbgeneraldate))
response.write("<br />")
response.write(FormatDateTime(date(),vblongdate))
response.write("<br />")
response.write(FormatDateTime(date(),vbshortdate))
response.write("<br />")
response.write(FormatDateTime(now(),vblongtime))
response.write("<br />")
response.write(FormatDateTime(now(),vbshorttime))
%>

<p>
Syntax for FormatDateTime: FormatDateTime(date,namedformat).
</p>

</body>
</html>
_____________________________________________

You will get this:

05.04.2003
5. April 2003
05.04.2003
12:56:29
12:56
Syntax for FormatDateTime: FormatDateTime(date,namedformat).


Notice the use of date() for date and now() for time.

Hope this helps

Bill


lneisius
Posted: 04/05/2003, 5:22 AM

Confused me even more Bill, general date returns both the date and time in vbscript acording to MS acces help. CCS uses the Now() capability of vbscript any time you set the default value of a listbox or label to current date and time. I am not as concerned as to what format is placed into the dbase as this can be changed in the project settings, but the fact that nothing is written to the dbase is the issue.
lneisius
Posted: 04/05/2003, 6:39 PM

I tried the following sql and it will place data in the database but the database is showing time instead of date.

SQL = "UPDATE Members SET Visits=" & Session("MemberVisits") & ", LastLogin = 1/1/02 WHERE MemberID=" & Session("MemberID")
Connection.Execute(SQL)

It seems that any text box entry will work correctly but that the sql is the problem. Even if I use a default value of date() or Now() the date is placed correctly in the database but any manual coded sql with date() will show as time and Now() will cause some kind of error that will not place any data in the database even though no errors are displayed.
Bill Noble
Posted: 04/06/2003, 11:06 AM

Hi lneisius


After member login has been completed, they are redirected to the membership page.

I have this custom code(server) in the before show event of the membership page. (and it works).

This is a direct copy from my site.

'Custom Code @45-73254650
' -------------------------
DIM BNConnection
Set BNConnection = New clsDBConnection1
BNConnection.Open
BNConnection.Execute("UPDATE users SET date_last_login=#"&now()&"# WHERE user_id ="& CCGetUserID)
BNConnection.Close

' -------------------------
'End Custom Code

Hope this helps
Bill
lneisius
Posted: 04/07/2003, 2:27 PM

Thanks Bill!!!!
Worked like a charm as far as I can see so far! Do you know what the # symbol is for or what it's doing?
Bill Noble
Posted: 04/08/2003, 12:17 AM


The # is needed by Access when storing dates
(I think there may be something in the KB on the subject.)

Pleased I could help

Bill

   


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

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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