i had a problem with this codes.. this codes will retrieve image from database that will based on the employeenumber.

 Dim CN As New OleDbConnection(cnString)
        CN.Open()
        daImage = New OleDbDataAdapter()
        daImage.SelectCommand = New OleDbCommand("SELECT * FROM EmployeeProfile ", CN)
        dsImage = New DataSet("dsImage")

        Dim dataTable As DataTable = dsImage.Tables(0)

        If IDPicturePB.Image IsNot Nothing Then

            IDPicturePB.Image.Dispose()
        End If

        Dim fsImage As New FileStream("image.jpg", FileMode.Create)

        For Each dataRow As DataRow In dataTable.Rows
            If dataRow(0).ToString() = EmployeeNumberIDTB.Text.ToString() Then

                Dim blob As Byte() = DirectCast(dataRow(1), Byte())

                fsImage.Write(blob, 0, blob.Length)
                fsImage.Close()
                fsImage = Nothing

                IDPicturePB.Image = Image.FromFile("image.jpg")
                IDPicturePB.SizeMode = PictureBoxSizeMode.StretchImage
                IDPicturePB.Refresh()
            End If
        Next

error in this line : Dim dataTable As DataTable = dsImage.Tables(0)
can someone explain it to me? :(
error is Cannot find table 0.

You didn't say what the error message is but where in your code did you create a NEW datatable like:

Dim dataTable As NEW DataTable = dsImage.Tables(0)

Sorry, my mistake....you need to add the table that you apparently want to name 'dataTable'. Try this

        Dim dsimage = New DataSet("dsImages")
        dsimage.Tables.Add("dataTable")

        MsgBox(dsimage.Tables.Count)

        MsgBox(dsimage.Tables(0).TableName)

Edited 4 Years Ago by themaj

Why are you doing select * from if you only need Image from DB? and also check for the data after Dim dataTable As DataTable = dsImage.Tables(0).

This article has been dead for over six months. Start a new discussion instead.