Binary documents seem to hang when closing...

G

Guest

I have a database full of word and excel documents!

The documents open fine however when a user goes to close the document the
application seems to crash...

Any ideas???

Thanks...

.... CODE ...

Dim ID As String
ID = CType(Request.QueryString("ID"), Integer)
If Len(ID) < 1 Then
lblNoContent.Visible = True
lblNoContent.Text = "There was an error opening the file you
requested..."
Else

Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("GetFileData", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim objFileData As New SqlParameter

objFileData = cmd.Parameters.Add("@FileID", SqlDbType.NVarChar)

objFileData.Direction = ParameterDirection.Input
objFileData.Value = ID

Dim myReader As SqlDataReader = cmd.ExecuteReader()


While myReader.Read
Response.Expires = 0
Response.Buffer = True
Response.Clear()
Response.ContentType = myReader.Item("fileType") 'Setting
the file type of the retrieved file
'Response.AddHeader("Content-Disposition", "Inline;
filename=mypdf.pdf") 'Sets the "Save As" file name for the document...
Response.BinaryWrite(myReader.Item("Data")) 'Writing the
File retrieved from the database
Response.Flush()
Response.Close()

End While

myReader.Close()
Myconn.Close()

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top