How to Store Image in SQL server 2000

  • Hi All,

    I want to store an image file of any extension (gif,jpeg etc.) in SQL Server 2000. How can do that, it would be great if some one can help me in this regards. Some code snippet example will be great.

    Kind Regards,

    Affan

    mabutt@ssi.com.pk

  • CREATE TABLE dbo.SC_Image

    (

    ID int NOT NULL ,

    ImageFile image NOT NULL,

    CONSTRAINT PK_SC_Image PRIMARY KEY CLUSTERED (ID)

    )

    GO

    CREATE PROCEDURE StoreImage

    (@ID Int, @ImageFile Image)

    AS

    INSERT INTO SC_Image (ID, ImageFile) VALUES (@ID, @ImageFile)

    GO

    CREATE PROCEDURE LoadImage

    (@ID Int, @ImageFile Image OUT)

    AS

    SELECT @ImageFile = ImageFile FROM SC_Image WHERE ID = @ID

  • Thanx,

    But this will load to and from DB, i just need to ask that will i be using ADO steram object in my application to load and store image from DB using these SPs.

    Kind Regards,

    Affan

    mabutt@ssi.com.pk

  • create a record set, set the value of the image field to the stream object

    To database:

    rs.fields(0).value = streamobject.read

    From database:

    streamobject.write rs.fields(0).value

    abdul


    abdul

Viewing 4 posts - 1 through 3 (of 3 total)

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