how 2 insert image in a table

  • Hi,

    Could anyone tell me as how to insert images in a image data type field. Also how to retrieve. I wanted to retrive the images and show in a web page. Any idea?

    Thanks in advance,

    Rahul

  • Hi,

    if you're doing this with ADO take a look at the ADO Stream Object. A code snippet follows when I find it. Should soon be the case

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Here we go

    This one retrieves binary data and writes to file

    Dim strStream As ADODB.Stream

    sql = "SELECT * FROM mails_attachments WHERE id=" & CLng(DataList3.BoundText)

    Set rs = New ADODB.Recordset

    cnnArchive.Open SNIPPET_STRING

    rs.Open sql, cnnArchive, adOpenDynamic, adLockOptimistic, adCmdText

    Set strStream = New ADODB.Stream

    strStream.Type = adTypeBinary

    strStream.Open

    strStream.Write rs.Fields("MsgAttachment").Value

    strStream.SaveToFile CommonDialog1.FileName, adSaveCreateOverWrite

    This one stores binary data

    Dim strStream As ADODB.Stream

    Set strStream = New ADODB.Stream

    strStream.Type = adTypeBinary

    strStream.Open

    strStream.LoadFromFile sFileName

    DoEvents

    .Fields("MsgAttachment").Value = strStream.Read

    HTH

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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