July 7, 2004 at 3:17 am
I have a table in SQL Server that has an Image (also called BLOB) type field.
I would like to know what kind of data is stored in the blob fields. I know that there are MS Word blobs, pdf blobs, and gif blobs but I dont know which are which.
Is there any way to determine what kind of info is stored in these blob fields.
i do have an in-elegant way (with asp:
response.binarywrite rsBlob.Fields("binary_doc").GetChunk(1000)
which yields some gobbledygook:
- ÿÿÿÿDocumentWord.Document.8Word.Document.8|ÐÏࡱá>þÿ
but with a visual examintaion it is possible to spot if its Word or not
Is there a more ELEGANT way??????
Thanks
July 8, 2004 at 5:28 pm
In Image(Blob) Data Type you can put any data, pdf, word, gif, your own class object into the database table field.
Using ADODB stream to load the object into field:
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile (App.Path & "\" & "acrobat.pdf")
rsDocument.AddNew
rsDocument.Fields("Data").Value = mstream.Read
rsDocument.Update
You can still use the GetChunk methods and do the same thing, in some cases give you control over the data.
Putting files into database is not an ideal for large number of files. You will get performance problems. The best is to keep it off site on disk and reference to the file.
Hope this helps.
July 12, 2004 at 10:39 pm
mstream is an ado stream,
rsdocument is ??
how declared ??
how linked to a table, coumn ??
next,
how to read an image data type (blob):
1. Into a file
2. Into memory
EM
July 20, 2004 at 10:01 pm
Assumeded that you have a table called ImageData with ImageNo varchar(50), Data(Image) Fields
Dim mstream As ADODB.Stream
Dim rsDocumentAs ADODB.Recordset
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
rsDocument.Open "Select top 1 * from ImageData", strActiveConnectionString, adOpenKeyset, adLockOptimistic)
mstream.LoadFromFile (App.Path & "\" & "acrobat.pdf")
rsDocument.AddNew
rsDocument.Fields("Data").Value = mstream.Read
rsDocument.Fields("ImageNo").Value = "acrobat"
rsDocument.Update
'To Retrieve it from the server
Dim rsImage As ADODB.Recordset
Dim mstream As ADODB.Stream
Set rsImage = New ADODB.Recordset
rsImage.Open "select * from ImageData where ImageNo = '" & strImageFile & "'", strActiveConnectionString, adOpenStatic
If rsImage.RecordCount <> 0 Then
Set mstream = New ADODB.Stream
mstream.Type = 1
mstream.Open
mstream.Write rsImage.Fields("Data").Value
mstream.SaveToFile strFileName, adSaveCreateOverWrite
mstream.Close
Else
msgbox "Record not found with given image name file"
End If
rsImage.Close
Hope this helps a bit more...
Please look up on the Microsoft MSDN for future help.
February 16, 2010 at 4:51 am
it does n't work for me.I can save the Pdf file and i can not open it.
it is saying that "Adobe reader could not open pdf.because it is either not a supported file type or because the file has been damaged".
Can any one give me the solution?
thanks
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply