Question: I need to generate my click / impression URL's dynamically. Is there a way of adding impression tracking to a double click video tag? I understand with clicks, the "click=" followed by the URL would do, is there an equivalent for impression tracking?

```
here is an example of an ad tag:
http://ad.doubleclick.net/adj/N6103.762836.GOINGOFFSCRIPT.COM/B5926988;sz=300x250click=%dfaurl%;

```

Answer: 
You're loading a load of data into the `GridView` but nothing is being loaded into your `imageData` variable. So we'll just connect to the database and pull that data out. I'm assuming your image column is called `imageData` but please change as appropriate.

```
Dim EmployeeID As Integer

If (Not (context.Request.QueryString("EmployeeID")) Is Nothing) Then

    EmployeeID = Convert.ToInt32(context.Request.QueryString("EmployeeID")) 

Else

    Throw New ArgumentException("No parameter specified")

End If 

Dim imageData() As Byte = {}

' get the image data from the database using the employeeId Querystring

Using con As New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))

    Using cmd As New SqlCommand("SELECT imageData FROM EmployeeTable WHERE EmployeeID = @EmployeeID", con) 'select imageData column, change column name as appropriate

        cmd.Parameters.AddWithValue("@EmployeeID", EmployeeID)

        Try

            con.Open()

            Using rdr As SqlDataReader = cmd.ExecuteReader()

                If rdr.Read() Then

                    imageData = CType(rdr("imageData"), Byte()) 'convert imageData column from result set to byte array and assign to variable

                End If

            End Using

        Catch ex As Exception

            'do any error handling here

        End Try

    End Using

End Using

context.Response.ContentType = "image/jpeg"
context.Response.BinaryWrite(imageData)

```
Changed the code in the handler to this:

```
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    Dim EmployeeID As Integer

    If (Not (context.Request.QueryString("EmployeeID")) Is Nothing) Then

        EmployeeID = Convert.ToInt32(context.Request.QueryString("EmployeeID"))

    Else

        Throw New ArgumentException("No parameter specified")

    End If

    Dim Image() As Byte = {}

    ' get the image data from the database using the employeeId Querystring

    Dim con As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString").ToString)

    Dim cmd As New SqlCommand("SELECT Image FROM EmployeeTable WHERE EmployeeID = @EmployeeID", con)
    'select imageData column, change column name as appropriate

    cmd.Parameters.AddWithValue("@EmployeeID", EmployeeID)

    Try

        con.Open()

        Dim rdr As SqlDataReader = cmd.ExecuteReader()

        While rdr.Read()

            Image = CType(rdr("Image"), Byte())
            'convert imageData column from result set to byte array and assign to variable
        End While

    Catch ex As Exception

        'do any error handling here

    End Try

    context.Response.ContentType = "image/jpeg"
    context.Response.BinaryWrite(Image)

End Sub

```

Worked for me, may be it will work for you too...