Hi
I need to add a download counter to know how many times my BLOB data is read and displayed from the database (to determine traffic). How and where can I add this counter? Many thanks!
I have a dynamically generated list of links such as
<a href="page.aspx?DocID=IDhere">
Document filename</a>
which direct to a display page.
My display page code looks like:
Protected Sub Page_Load
Dim DocID As Integer = Convert.ToInt32(Request.QueryString("DocID"))
Dim connStr As String = conn string here
Dim SqlCmd1 As String = "SELECT DocID, DocBD, Filename, MIMEType WHERE DocID=@DocID"
Dim conn As SqlConnection = New SqlConnection(connStr)
Dim Cmd1 As SqlCommand = New SqlCommand(sqlCmd1, conn)
With Cmd1.Parameters
.Add(New SqlParameter("@DocID", DocID)
End With
Try
conn.Open()
Dim myReader As SqlDataReader = Cmd1.ExecuteReader
If myReader.Read Then
Response.ClearContent()
Response.AddHeader("content-disposition", "inline; filename=" & myReader("Filename"))
Response.ContentType = myReader("MIMEType").ToString()
Response.BinaryWrite(myReader("DocBD"))
Response.End()
Else
Label1.Text = "The document you requested doesn't exist in the database. Please contact the document owner"
End If
myReader.Close()
Catch ex As Exception
Label1.Text = ex.Message()
Finally
conn.Close()
End Try
End Sub