Z
znubbe
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.Codepage = 65001
Response.Charset = "utf-8"
response.clear
response.expires = 0
response.buffer = true
'Response.ContentType = "application/pdf"
Response.ContentType = "application/ms-word"
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=PBase;Data Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("ADODB.Recordset")
Call oRS.Open(strSQL, conn, 2, 2)
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = 1
oStream.Open
oStream.LoadFromFile "C:\Inetpub\wwwroot\PB_Kansli\Files\luculli.doc"
oRS.Fields("NEWS_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("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=PBase;Data Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("ADODB.Recordset")
Call oRS.Open(strSQL, conn, 2, 2)
Response.AddHeader "Content-Disposition", "inline;filename=test.doc"
Response.BinaryWrite 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:
Ðࡱက>?ku?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
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.Codepage = 65001
Response.Charset = "utf-8"
response.clear
response.expires = 0
response.buffer = true
'Response.ContentType = "application/pdf"
Response.ContentType = "application/ms-word"
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=PBase;Data Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("ADODB.Recordset")
Call oRS.Open(strSQL, conn, 2, 2)
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = 1
oStream.Open
oStream.LoadFromFile "C:\Inetpub\wwwroot\PB_Kansli\Files\luculli.doc"
oRS.Fields("NEWS_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("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=PBase;Data Source=BURKEN"
strSQL = "Select * From News where NEWS_ID=1"
Set oRS = CreateObject("ADODB.Recordset")
Call oRS.Open(strSQL, conn, 2, 2)
Response.AddHeader "Content-Disposition", "inline;filename=test.doc"
Response.BinaryWrite 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:
Ðࡱက>?ku?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