Results 1 to 19 of 19

Thread: [2005] Want to display several images from DB

Threaded View

  1. #1

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

    [2005] Want to display several images from DB

    I worked out this code in another thread (thanks Mendhak!)

    Code:
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim dcn As New SqlConnection
            dcn.ConnectionString = "Server=fps-lap-sz\sqlexpress; Initial Catalog=Stufiles; Integrated Security=SSPI"
            Try
                dcn.Open()
                Dim drc As New SqlCommand
                drc.Connection = dcn
                drc.CommandType = Data.CommandType.StoredProcedure
                drc.CommandText = "GetStuPhoto_P"
                drc.Parameters.Add(New SqlParameter("@StuId", Data.SqlDbType.VarChar, 255, Data.ParameterDirection.Input _
                                            , False, 0, 0, "", Data.DataRowVersion.Default, Request.QueryString("imageid")))
                Dim bytArrayContent As Byte() = DirectCast(drc.ExecuteScalar, Byte())
                'bytArrayContent = CType(dr.Item("ImageField"), Byte())
                Response.ContentType = "image/jpeg"
                Response.OutputStream.Write(bytArrayContent, 0, bytArrayContent.Length)
                Response.End()
                txtMessage.Text = "Student Displayed!"
            Catch ex As Exception
                txtMessage.Text = "Student Not Found!"
            End Try
    Just to prove that I could display images from a database.

    Now I want to change it so that the stored procedure GetStuPhoto_P returns many images.

    I would like to display several horizontally on the page (like 3 maybe) and then repeat each row until all images are show.

    With maybe the student name under each image.

    So I started changing this to have an IMAGE CONTROL - thinking that would be needed. But I've got no idea how to bind that to a datareader - there is no DATASOURCE property.

    And the REPEATER info in the VS help files is not too clear (I've never done web/asp work - so this is all new to me).

    Any help or direction would be appreciated.
    Last edited by szlamany; Jan 21st, 2008 at 04:24 PM.

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