Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQL server image field

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Related Topics:
Storing image file to MSSQL by VB - Dear all, I would like to store a image file to my MSSQL. how can i program it .. ? Thanks all

ADOX and Catalog and default field value - I am using VB6 and ADOX 2.7. I need to add a field (column) to a Catalog's Table's Column's with a default value. Is there a way to do this? I don't see it in the when it is nor when it has been appended to..

Accessing data on a web server - I have written a VB6 app for a user that uses ADO to connect to a MySQL database (through the MyODBC driver). Not being much of a internet the user asked me if it is possible to move the the database to a web server and have the client program..

DataEnvironment Connection to a remote SQL Server database - Hi, I am trying to connect one PC (win98) to SQL Server located on another PC (winxp1) but am failing with an error message: Test failed because of an error in provider. Server does..

runtime error 3021 and user permissions - I have a VB6 that uses ADO 2.7 to access an database. I have found on Windows XP and 2000, that if the user is not part of the group, they receive: error 3021. Either BOF or EOF is true, or the current record..
Next:  randomize  
Author Message
Stephanie Stowe

External


Since: Feb 15, 2005
Posts: 1



(Msg. 1) Posted: Tue Feb 15, 2005 4:16 pm
Post subject: SQL server image field
Archived from groups: microsoft>public>vb>database>ado (more info?)

I have a problem related to a field in a SQL table whcih is an "image"
datatype. The powers that be here claim it is a bmp. I think it is not, or
that it is encrypted in some way. I would like to test my theory by reading
the data in the field and writing it to disk. Then I want to open my bmp and
see if I can see it. I have never done anything with blobs or anything other
than standard, non binary data. Does anyone have a little sample of reading
this kind of data out of a table. I have seen the GetChunk method but I do
not see how to write this to the file system. If you can point me in the
direction of the best file system object(s) instead.... I think I just need
a nudge. Thanks.

 >> Stay informed about: SQL server image field 
Back to top
Login to vote
Mark J. McGinty

External


Since: Aug 31, 2003
Posts: 30



(Msg. 2) Posted: Thu Feb 17, 2005 10:39 am
Post subject: Re: SQL server image field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Stephanie Stowe" <IwishIcould RemoveThis @nospam.com> wrote in message
news:%23oVINt5EFHA.2756@TK2MSFTNGP15.phx.gbl...
 >I have a problem related to a field in a SQL table whcih is an "image"
 >datatype. The powers that be here claim it is a bmp. I think it is not, or
 >that it is encrypted in some way. I would like to test my theory by reading
 >the data in the field and writing it to disk. Then I want to open my bmp
 >and see if I can see it. I have never done anything with blobs or anything
 >other than standard, non binary data. Does anyone have a little sample of
 >reading this kind of data out of a table. I have seen the GetChunk method
 >but I do not see how to write this to the file system. If you can point me
 >in the direction of the best file system object(s) instead.... I think I
 >just need a nudge. Thanks.


First off, you're over-thinking the "image" thing, it's just a name, no
transformations are performed. If you save Word Document data into an image
file, you'll get Word Doc back out. (You'd probably want to convert bmp's
to jpg's before storing them, but that's beside the point -- SQL won't do
that for you.)

And here's your nudge. Smile

Good Luck,
Mark



Dim FileName As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

'''''
' assume recordset is opened and positioned, that the first
' column of the recordset is of type image, and the string
' FileName has been assigned with a valid, fully-qualified
' file name.
'
''''''

Dim oStr As ADODB.Stream
Set oStr = New ADODB.Stream

oStr.Mode = adModeReadWrite
oStr.Type = adTypeBinary
oStr.Open

' load binary contents of a file into stream
'
oStr.LoadFromFile FileName
oStr.Position = 0

' create a record and write the file to blob field by reading it
' from the stream
'
rs.AddNew
rs.Fields(0).Value = oStr.Read()
rs.Update


''''''''''''''''''
' or read the blob from the db and save it to file
'
oStr.Write rs.Fields(0).Value
oStr.Position = 0

oStr.SaveToFile FileName, adSaveCreateNotExist<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: SQL server image field 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]