November 10, 2006 at 12:18 am
I have a business problem.
We create Excel files in xls-format in an AS 400 iSeries machine.
We need to expose those files in a web application.
The general idea is to
1. Store the xls as a blob in DB2.
2. Connect to the AS400 DB2 database by linked server and retrieve the blob.
3. Store the blob in a SQL server table.
This all works fine.
However how do I retrieve the blob from sql server and send away it as an
.xls-file?
Since the blob is in binary format I need to convert it to an .xls-file.
It there some way of doing that in a procedure?
Or is that a bad idea, should I use a program instead?
Further ideas?
November 10, 2006 at 2:24 pm
you don't fiddle with image/binary fields at the SQL server level usually; you do it an an application level, like with VB, VB.NET, Delphi, whatever.
Here's the code as an example from vb; it takes the image field(in this case a .dll or .exe stored in the db) and creates a file on the harddrive.
an image filed simply holds the binary format of the data; doesn't matter if it is XLS, PDF, whatever.
Dim rs As ADODB.Recordset
Dim binObj As ADODB.Stream
Set rs = New ADODB.Recordset
sql = "SELECT * FROM HDSMODULES WHERE MODULENAME='myProgram.exe' AND MODULEDATA IS NOT NULL"
rs.Open sql, glbcn, adOpenDynamic, adLockOptimistic
If Not (rs.BOF And rs.eof) Then
Set binObj = New ADODB.Stream
binObj.Type = adTypeBinary
binObj.Open
binObj.Write rs!MODULEDATA
binObj.SaveToFile App.Path & "\" & rs!MODULENAME, adSaveCreateOverWrite
binObj.Close
Set binObj = Nothing
end if
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy