Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2004, 11:11 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>


 
Old October 1st, 2004, 11:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Don't cross post - http://p2p.wrox.com/topic.asp?TOPIC_ID=20083

Though I answered it already.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can share my databse lalit_84m SQL Server 2000 1 May 31st, 2007 01:05 AM
Right-Click or Double-Click Combobox? panuvin C# 2005 3 June 15th, 2006 04:30 PM
asp-wml -databse andy11983 Classic ASP Basics 0 April 12th, 2004 05:51 PM
Read-only Databse! fonsy2 Classic ASP Databases 5 December 15th, 2003 03:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.