znubbe@hotmail.com wrote:[color=blue]
> 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.do c"
> 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"[/color]
Why retrieve all the columns? It's usually a good idea to specify the column
you wish to retrieve...
[color=blue]
> 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
>[/color]
I think you need to use a Stream object. Try this:
If Not ors.eof then
Set FStream = Server.CreateObject("ADODB.Stream")
FStream.Type = adTypeBinary
FStream.Open
FStream.write rs("NEWS_DATA").Value
FStream.Position = 0
Response.AddHeader "Content-Length", FStream.size
Response.Charset = "UTF-8"
Response.BinaryWrite FStream.Read
Response.flush
end if
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.