Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a word document from sql server

Status
Not open for further replies.

jordan11

Technical User
May 24, 2003
150
GB
I am trying to display a word documnet from my sql server database using

<%
set rs=server.createobject("ADODB.recordset")
txtSQL= "SELECT filedata FROM clientcv WHERE clientID = '" & REQUEST("clientid") & "'"
Set rs=conn.Execute(txtSQL)



'Response.Expires = 0
'Response.Buffer = TRUE
'Response.Clear



Response.ContentType = "application/msword"


Response.BinaryWrite RS("filedata")


RS.Close
Set RS = Nothing
%>


but the results I get is


ÐÏࡱá





Thanks in advance
 
What type field do you have the document stored in?
And what method did you use to upload it to the database?

I use very similar code to pull documents down from my database.
The one difference is I store the content type in another field and pull that down as well so I can have different types of files without having to worry about determining the correct content type to display them.

Code:
    ' Retrieves binary files from the database
    Response.Buffer = True
    mySQL = "Select File_Type, File_Data FROM mytable Where RowNum ='" & FileID & "'"

    Set rs = conn.execute(mySQL)
    If Not rs.EOF Then
       Response.ContentType = rs("File_Type")
       Response.BinaryWrite rs("File_Data")
    Else
      Response.Write "The file does not exist."
    End If

Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top