HairyMonkeyMan
September 20th, 2004, 06:21 AM
Greetings and Salutations VBScripters;
I have been developing a server side directory explorer in asp.... This is working ok.
On this site, my users log in and they're username is stored as session variable. I am currently trying to develop a logging system that will save the username, time and link clicked to a database. To accomplish this, I realise that I need both clientside and serverside code. Here is my client-side code:
<script language="vbscript">
' ***** Log file downloads (to Database)
Sub LogDownloadToDB(strFileName)
' Dimension Variables
Dim Connection 'Database Connection Variable
Dim strSQL 'SQL string
Dim rsLog 'Database Recordset Variable
'Create a connection odject
Set Connection = CreateObject("ADODB.Connection")
' Connect to DB
With Connection
.Provider= "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = ""
.Open "www.mnd.co.uk/database/userlog.mdb"
End With
' Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM tblUserLog"
' Create a recordset object
Set rsLog = CreateObject("ADODB.Recordset")
' Query the database
rsLog.Open strSQL, Connection.ConnectionString, 1,3
' New Item
rslog.AddNew
rsLog.Fields(1).Value=Session("strUserName")
rsLog.Fields(2).Value=now
rsLog.Fields(3).Value=strFileName
rsLog.Update
rsLog.Close
set rsLog=Nothing
set Connection=Nothing
End Sub
</script>
I call this from here;
<A target=_blank onclick="vbscript:LogDownloadToDB('<%= sDir %><%= sFileName %>')"
HREF="<%= sDir %><%= sFileName %>">
which is server-side when the links are being created. The error I get when I click on a link is;
Safety settings on this computer prohibit accessing a data source on another domain.
Thanks for your time, and hope you can help :wave:
I have been developing a server side directory explorer in asp.... This is working ok.
On this site, my users log in and they're username is stored as session variable. I am currently trying to develop a logging system that will save the username, time and link clicked to a database. To accomplish this, I realise that I need both clientside and serverside code. Here is my client-side code:
<script language="vbscript">
' ***** Log file downloads (to Database)
Sub LogDownloadToDB(strFileName)
' Dimension Variables
Dim Connection 'Database Connection Variable
Dim strSQL 'SQL string
Dim rsLog 'Database Recordset Variable
'Create a connection odject
Set Connection = CreateObject("ADODB.Connection")
' Connect to DB
With Connection
.Provider= "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = ""
.Open "www.mnd.co.uk/database/userlog.mdb"
End With
' Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM tblUserLog"
' Create a recordset object
Set rsLog = CreateObject("ADODB.Recordset")
' Query the database
rsLog.Open strSQL, Connection.ConnectionString, 1,3
' New Item
rslog.AddNew
rsLog.Fields(1).Value=Session("strUserName")
rsLog.Fields(2).Value=now
rsLog.Fields(3).Value=strFileName
rsLog.Update
rsLog.Close
set rsLog=Nothing
set Connection=Nothing
End Sub
</script>
I call this from here;
<A target=_blank onclick="vbscript:LogDownloadToDB('<%= sDir %><%= sFileName %>')"
HREF="<%= sDir %><%= sFileName %>">
which is server-side when the links are being created. The error I get when I click on a link is;
Safety settings on this computer prohibit accessing a data source on another domain.
Thanks for your time, and hope you can help :wave: