p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   .NET 4.5.1 and Visual Studio 2013 General Discussions (http://p2p.wrox.com/net-4-5-1-visual-studio-2013-general-discussions-759/)
-   -   Binding A SQL Image Field To A Picture Box (http://p2p.wrox.com/net-4-5-1-visual-studio-2013-general-discussions/98997-binding-sql-image-field-picture-box.html)

testsubject May 27th, 2016 06:39 PM

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:

Code:

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

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

        Dim bytBLOBData() As Byte = dsPODs.Tables(0).Rows(0)("ImageData")
        Dim stmBLOBData As New MemoryStream(bytBLOBData)
        picPODViewer.Image = Image.FromStream(stmBLOBData)
       
        daTransport.Dispose()
        daTransport = Nothing
        dsPODs.Dispose()
        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


All times are GMT -4. The time now is 08:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.