Johan Hanekom writes "Is their a better why to do the following with just a SQL Query rather than ADO?
Server: Ms SQL 6.5
OS: WinNT4/2k
'open connection to database
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtemp=dsntemp & "DBQ=" & server.mappath("frontdoor/data_s/hardwired_stats.mdb")
SqlStatCheck = "SELECT * FROM tblStat where stat_time=" & DatePart("h",now()) & " and stat_day=" & DatePart("d",now()) & "and stat_month=" & DatePart("m",now())
Set RsStatCheck = Server.CreateObject("ADODB.Recordset")
RsStatCheck.Open SqlStatCheck, DSNtemp, 3, 3
'check to see if their is a record that is current
if RsStatCheck.eof then
'doesn't look like their is so we then add one
RsStatCheck.AddNew
RsStatCheck("stat_time") = DatePart("h",now())
RsStatCheck("stat_day") = DatePart("d",now())
RsStatCheck("stat_month") = DatePart("m",now())
RsStatCheck("stat_hit") = 1
RsStatCheck.Update
'response.write "Records Added"
else 'response.write "Records Found"
'update / add a value for the incoming hit
RsStatCheck("stat_hit") = RsStatCheck("stat_hit") + 1
RsStatCheck.Update
end if
'we redirect the user
Response.Redirect("frontdoor/default.asp")
Response.End
"