58 lines
1.6 KiB
Plaintext
58 lines
1.6 KiB
Plaintext
|
<% @Language = "VBScript" %>
|
||
|
<html>
|
||
|
|
||
|
<head>
|
||
|
<title>New Page 1</title>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<%
|
||
|
On Error Resume Next
|
||
|
myPageName = "Home Page"
|
||
|
|
||
|
connection_string = "DRIVER={SQL SERVER};Server=MAHESHJ;UID=sa;DATABASE=employee"
|
||
|
|
||
|
|
||
|
Set myConn = Server.CreateObject("ADODB.Connection")
|
||
|
myConn.Open connection_string
|
||
|
Set RS = Server.CreateObject("ADODB.RecordSet")
|
||
|
|
||
|
sqlString = "SELECT ID,pageName,pageCount,dateCreated,dateHit"
|
||
|
sqlString = sqlString & " FROM counter
|
||
|
sqlString = sqlString & " WHERE pageName = '" & myPageName & "'"
|
||
|
RS.Open sqlString,myConn
|
||
|
|
||
|
if NOT(Err.Number <> 0) then
|
||
|
if RS.EOF or RS.BOF then
|
||
|
myCount = 1
|
||
|
myDateHit = Now()
|
||
|
sqlString = "INSERT INTO counter"
|
||
|
sqlString = sqlString & " (pageName,pageCount,dateCreated,dateHit)"
|
||
|
sqlString = sqlString & "SELECT '" & myPageName & "' AS pageName,"
|
||
|
sqlString = sqlString & " '1' AS pageCount,"
|
||
|
sqlString = sqlString & " #" & Now() & "# AS dateCreated,"
|
||
|
sqlString = sqlString & " #" & Now() & "# AS dateHit;"
|
||
|
myConn.Execute sqlString
|
||
|
else
|
||
|
myDateHit = RS("dateHit")
|
||
|
myNewCount = RS("myCount") + 1
|
||
|
sqlString = "UPDATE counter"
|
||
|
sqlString = sqlString & " SET myCount = " & myNewCount & ","
|
||
|
sqlString = sqlString dateHit = #" & Now() & "#"
|
||
|
sqlString = sqlString & " WHERE ID = " & RS("ID")
|
||
|
myConn.Execute sqlString
|
||
|
end if
|
||
|
else
|
||
|
response.write "There were errors" & vbCr
|
||
|
end if
|
||
|
%>
|
||
|
|
||
|
|
||
|
<%
|
||
|
Response.Write myCount & " hits since " & RS("dateCreated") & "."
|
||
|
Response.Write " Last Hit on " & myDateHit & "<br>" & vbCr
|
||
|
%>
|
||
|
|
||
|
</body>
|
||
|
</html>
|