Hi,
I hope anyone can help me with this problem.
I have a field of image type in a SQL 2000 database. I'm using this
code to insert a document:
Dim conn
Dim rs
Dim oStream
Session.Codepag e = 65001
Response.Charse t = "utf-8"
response.clear
response.expire s = 0
response.buffer = true
'Response.Conte ntType = "applicatio n/pdf"
Response.Conten tType = "applicatio n/ms-word"
Set conn = CreateObject("A DODB.Connection ")
conn.Open "Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist
Security Info=False;Init ial Catalog=PBase;D ata Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("A DODB.Recordset" )
Call oRS.Open(strSQL , conn, 2, 2)
Set oStream = CreateObject("A DODB.Stream")
oStream.Type = 1
oStream.Open
oStream.LoadFro mFile "C:\Inetpub\www root\PB_Kansli\ Files\luculli.d oc"
oRS.Fields("NEW S_DATA").Value = oStream.Read
oStream.Close
Set oStream =nothing
oRS.Update
oRS.Close
Set oRS =nothing
conn.Close
Set conn = nothing
Data is put in the field and I'm using this code to retrieve it:
Set conn = CreateObject("A DODB.Connection ")
conn.Open "Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist
Security Info=False;Init ial Catalog=PBase;D ata Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("A DODB.Recordset" )
Call oRS.Open(strSQL , conn, 2, 2)
Response.AddHea der "Content-Disposition", "inline;filenam e=test.doc"
Response.Binary Write oRS("NEWS_DATA" )
oRS.Close
Set oRS =nothing
conn.Close
Set conn = nothing
The problem is that the output is nothing like the orginal. Instead of
a word document I get this:
Џࡱက>?k u?jx怀?????? ??????????????? ??????????????? ??????????????? ??????????????? ??????????????? ??????????????? ??????????쥁3
??bjbjC?C? ⃀!퀀!퀀v ,???l\\\\ ????vvv8 ? ??T
..⅀⅀⅀⅀ ?Ig sӈՈՈՈՈ Ո$? ?
???{''"{{ ??\\⅀? ???{\⅀\8 ӈ?{ӈ??w\ ?w⅀օ
ೌ,̳Ɓ??v{ Xww\$ 0T w* Ӈ(* w???\\\\
etc etc etc etc etc
What am I doing wrong?
Please help, I'm going crazy over this :-(
Thanks for your help,
Znubbe