View Single Post
  #1 (permalink)  
Old May 27th, 2016, 06:39 PM
testsubject testsubject is offline
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2005
Location: , , .
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Binding A SQL Image Field To A Picture Box

I hope you can help me as I have been searching Google all over to try and get some definitive answers.

I'm using Visual Studio Enterprise 2015, Visual Basic, Windows Forms Applications.

This is what I have so far:

        Dim dsPODs As DataSet
        Dim daTransport As SqlDataAdapter
        Dim conTransport As New SqlConnection("...")

        Dim PITSGetPODDetail As New SqlCommand()
        PITSGetPODDetail.Connection = conTransport
        PITSGetPODDetail.CommandText = "ssp_PITSGetPODDetail"
        PITSGetPODDetail.CommandType = CommandType.StoredProcedure
        PITSGetPODDetail.Parameters.AddWithValue("@JobNumber", Int16.Parse(JobNumber))

        dsPODs = New DataSet()

        daTransport = New SqlDataAdapter(PITSGetPODDetail)
        daTransport.Fill(dsPODs, "PODDetail")

        Dim bytBLOBData() As Byte = dsPODs.Tables(0).Rows(0)("ImageData")
        Dim stmBLOBData As New MemoryStream(bytBLOBData)
        picPODViewer.Image = Image.FromStream(stmBLOBData)
        daTransport = Nothing
        dsPODs = Nothing
The ssp_PITSGetPODDetail stored procedure simply returns any images which matches the Job Number passed to it. The field which is returned is a SQL Image field.

So, the above works to a fashion but needs further work which I am unable to fathom out.

What I would like to happen is a dataset is populated with a number of "images" and then use the Binding Navigator to move the Picture Box through the dataset.

Any help would be greatly appreciated.

Thank you
Reply With Quote