Inserting to databse on click
Hi Vijay & all,
I am showing some dynamic links from the database.On clicking these links users can download a file(report).What i want to do is as soon as they
click i want to insert that jobid and their username as well the system date on to an access databse table called LOg.This is to track the no. of downloads
for a report.Here is the code.
How can i proceed.Pls help with code.Thanks
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<%
If Session("user") = "" Then
Response.Redirect "login.html"
End If
%>
<table border=1>
<th>Report Name</th><th>Date Created</th>
<%
Dim objConn ' Connection Name
Dim strConn ' Connection String
Dim objRS ' Recordset Variable
Dim strSQL ' variable for SQL statement
Dim intTotalColumns
Dim intCounter
Const adOpenStatic = 3
Const adLockReadOnly = 1
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("asp.mdb") & ";"
objConn.Open strConn
strSQL = "SELECT a.ReportName, a.url2,a.dt,a.jobid FROM table1 AS a, email AS b WHERE a.jobid=b.jobid and b.UNAME='" & Session("user") & "' order by a.ReportName"
objRS.open strSQL, objConn, adOpenStatic, adLockReadOnly
if objRS.EOF then
Response.write "No Subscriptions in your account"
end if
do while not objRS.EOF
%>
<tr><td><a href="http://mycompany/mydept/reports/reports/<%=objRS("url2")%>"><%=objRS("url2")%></A></td>
<td><%=objRS("dt") %></td><td><input type=hidden name="what" value="<%=objRS("jobid")%> "></td>
<%
objRS.MoveNext
loop
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
</table>
|