Uploading Pictures in MSSQL 2000

  • And for Amit or for those that are still on SS2K (i.e. without SSIS), below is some VB script code that lets you transfer an image column to/from a file. Thus adoField is an ADO recordset field. The only thing I found that you need to be aware of is that for going from an image column to a file the image column needs to be the last column in your query, otherwise the ADODB.Stream Write method fails. If you can connect to DB2 using ADO this should work.

    Somewhere else on this forum I saw a one line OPENROWSET statement for doing this in SS2005. With Java it's pretty straight forward as well.

    Set objStream = CreateObject("ADODB.Stream")

    objStream.Type = 1 ' adTypeBinary

    objStream.Open

    objStream.Write adoField.Value

    objStream.SaveToFile "c:\temp\my.doc", 1 ' Options=adSaveCreateNotExist=1

    objStream.Close

    Set objStream = CreateObject("ADODB.Stream")

    objStream.Type = 1 ' adTypeBinary

    objStream.Open

    objStream.LoadFromFile "c:\temp\my.doc"

    adoField.Value = objStream.Read

    objStream.Close

Viewing post 16 (of 15 total)

You must be logged in to reply to this topic. Login to reply