Advertisement

09.02.2008 at 09:31AM PDT, ID: 23696557
[x]
Attachment Details

Having issues loading a 2007 word doc from blob file in asp.net web page

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3
Tags:

microsoft, visual studio 2003, .net 1.1, Asp.net web application

Hello experts,
I am having issues when I try to open a 2007 word doc from my asp.net page.  I get this messagebox when I try to open the document: The office open xml file "name here[1]" cannot be opened because there are problems with the contents.  When I click OK, I get this message:  Word found unreadable content in "doc name here[1]".  Do you want to recover the contents of the document?  When I click OK, the document loads up, but users may become concerned when they get these 2 messages.  

I found a solution, when I load up the content-type, I change it back to the old word content-type,
before I did this the file would not load up at all.  Is this a problem with how I am storing it in the database? Or is this a problem with how I am trying to retrieve it?  Here is my code for viewing the file.

 Sub read_blob_file(ByVal attach_id As Integer, ByVal row_id As Integer)
        Dim ssql As String
        Dim file_type, file_name As String
        Dim dr As OracleDataReader
        ssql = "SELECT File_type,File_name FROM text_doc_load WHERE attachment_id = " & attach_id & " and " & _
        "attach_row_id = " & row_id & ""
        dr = db_tool.GetData(ssql)
        Try
            While dr.Read
                file_type = dr.GetString(0)
                file_name = dr.GetString(1)
            End While
            dr.Close()
            If file_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" Then
                file_type = "application/msword"
            End If
             db_tool.objconn.Open()

            ssql = "select file_data FROM text_doc_load WHERE attachment_id = " & attach_id & " and " & _
        "attach_row_id = " & row_id & ""
            Dim cmd As OracleCommand = db_tool.objconn.CreateCommand()
            cmd.CommandText = ssql
            Dim _buf As Byte() = cmd.ExecuteScalar()
         
            'stream it back in the HTTP response
            Response.ContentType = file_type
             Response.AddHeader("Content-disposition", "attachment;filename=" & file_name)
            Response.BinaryWrite(_buf)
        Catch ex As Exception
            Dim l As String
            l = ex.Message
        Finally
            db_tool.objconn.Close()
        End Try
    End Sub
Answered By: prairiedog
Expert Since: 06/24/2003
Accepted Solutions: 496
Computer Expertise: Advanced
prairiedog has been an Expert for 5 years 6 months, during which he has posted 2288 comments and answered 496 questions. prairiedog is just one of 2257 experts in the Visual Studio Zone. 1 expert collaborated on this answer, which was graded an "A" by the asker.
 
 
 
 
20081119-EE-VQP-47 / EE_QW_2_20070628