Results 1 to 40 of 42

Thread: [RESOLVED] Image control - now getting picture from DB - datasource??

Threaded View

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Resolved [RESOLVED] Image control - now getting picture from DB - datasource??

    [edit] See Post # 35 for a solution on doing this without a temp file and without data binding

    Go to post #35 -> http://www.vbforums.com/showpost.php...2&postcount=35

    Ok - I've been loading pictures into an image control with LOADPICTURE like this:

    Code:
    .imgImage.Picture = LoadPicture(s1)
    with s1 being a string to the filepath and filename.

    Now we want to support storing pictures in our DB - and I got this code from looking at a thread by Si.

    Code:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.Open "Exec GetStuPhoto_P '" & s3 & "'", gCn
    Set .imgImage.DataSource = rs
    .imgImage.DataField = rs.Fields(0).Name
    rs.Close
    Set rs = Nothing
    Here I'm calling a stored procedure to grab the image from a table in the database.

    Do I need to use .DataSource - is that the only (and best) way to do this? I've never used the DataSource property before - it sounds like a "bound-control" and I'm worried about that.

    Any other opinions on this code?

    Thanks!
    Last edited by szlamany; Sep 28th, 2007 at 07:14 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width