Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27159

fill multiple picturebox controls from database

$
0
0
I'm trying to populate 1-12 picture boxes (PictureBox1- PictureBox12) from database but I can't understand how to do that. If we have (for example) 6 pictures in our database with code= 002, how to fill first 6 picturebox controls?

Here's an example of routine which opens DB:

Code:

Private Sub FillPicBoxes()
        Try
            Dim cn As New OleDb.OleDbConnection
            Dim cmd As OleDb.OleDbCommand
            Dim dr As OleDb.OleDbDataReader

            cn.ConnectionString = mstrConnection 'c:\picdb.mdb
            cn.Open()

            cmd = cn.CreateCommand()
            cmd.CommandText = "SELECT pic_s FROM pic_db where code=""002"""

            dr = cmd.ExecuteReader

'code for populating multiple picturebox controls needed here

            dr.Close()
            cn.Close()

            cmd.Dispose()
            cn.Dispose()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub


Thank you in advance

Viewing all articles
Browse latest Browse all 27159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>