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
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