Home All Groups Group Topic Archive Search About

Opening a file from pdf in ie

Author
14 Apr 2006 1:13 PM
Joris De Groote
Hi,

I have a small webpage that reads a file from sql server 2000 database and
opens it (added the code at the end of this question). Everything works, but
the file opens adobe acrobat reader in a new application. However, I want to
open the file in ie, so I don't get another box and everything.
How can I do this?

Thanks Joris


Private Sub DocumentOpenen()
Dim connectionString As String = "Server=VHTI2006\VHTITEST;Initial
Catalog=STS_VHTI2006_1_21001;Trusted_Connection=True"
Dim strSQL As String = "SELECT Content from Docs where LeafName ='" &
Documentnaam & "'"
Dim cnnDatabase As New SqlConnection(connectionString)
Dim myCommand As SqlCommand = New SqlCommand(strSQL, cnnDatabase)
Try
    myCommand.CommandTimeout = 500
    cnnDatabase.Open()
    Dim dreader As SqlDataReader = myCommand.ExecuteReader()
    If (dreader.Read()) Then
        Response.ContentType = "application/pdf"
        Response.BinaryWrite(dreader("Content"))
    End If
Catch ex As Exception
    Me.Label1.Text = ex.ToString
Finally
    cnnDatabase.Close()
End Try

Author
15 Apr 2006 11:50 AM
Paul Henderson
> I have a small webpage that reads a file from sql server 2000 database and
> opens it (added the code at the end of this question). Everything works, but
> the file opens adobe acrobat reader in a new application. However, I want to
> open the file in ie, so I don't get another box and everything.
> How can I do this?

It depends to some extent on what the browser chooses to do, but try
adding the header Content-Disposition: inline; to your response and see
if that helps. This question has been asked more than once before in
this group; you could try searching through past topics to see how
other people resolved this.

Bookmark and Share