Storing PPT or any document in database?

  • I want to store a file say a document or a ppt or a image file in a table of SQL server?

    (Note : I will be sending this file as an attachment to a mail generated from SQL server? )

    can any one help?

  • I have done this by using vb 6 and Microsoft ADO 2.5 and set it into the following project reference:

    dim rst as new adodb.recordset

    dim adoConn as new adodb.Connection

    You also have to open the connection with the database.

    'Open recordset....

    rst.Open "Select * from

    where ", adoConn, adOpenKeyset,

    adLockOptimistic

    'THIS FUNCTION SAVES AN IMAGE INTO AN IMAGE DATATYPE FIELD

    Private Function SaveImage()

    Dim mStream As New ADODB.Stream

    With mStream

    .Type = adTypeBinary

    .Open

    .LoadFromFile ""

    rst(""). Value = .Read

    rst.Update

    End With

    Set mStream = Nothing

    End Function

    'THIS FUNCTION LOAD IMAGE FROM IMAGE DATATYPE FIELD AND SAVE IT INTO A

    FILE.....

    Private Function LoadImage()

    Dim mStream As New ADODB.Stream

    With mStream

    .Type = adTypeBinary

    .Open

    .Write rst("")

    .SaveToFile "", adSaveCreateOverWrite

    End With

    Set mStream = Nothing

    End Function

    Aside from this method, you can use a picture control to store an image, put a picture control into a form, and call it PictureTemp.

    PictureTemp.DataField = "Immagine"'Set DataField....

    Set PictureTemp.DataSource = rst'Set DataSource

    You can use the PictureTemp.Picture property to get your image.

    Private Function LoadImage()

    Dim mStream As New ADODB.Stream

    With mStream

    .Type = adTypeBinary

    .Open

    PictureTemp.DataField = "Immagine"'Set DataField....

    Set PictureTemp.DataSource = rst'Set DataSource

    Set MSFGRID.CellPicture = PictureTemp.Picture'Show image into a cell of

    Microsoft FlexGrid

    End With

    Set mStream = Nothing

    End

    Function




    My Blog: http://dineshasanka.spaces.live.com/

  • See if this helps:

    http://www.microsoft.com/resources/documentation/sql/2000/all/reskit/en-us/part3/c1161.mspx

    --
    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