Private Sub ReadFileFromDataBase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butRead.Click
If txtOpen.Text = "" Or txtOpen.Text = Nothing Then Exit Sub
If File.Exists(txtOpen.Text) = True Then
File.Delete(txtOpen.Text)
End If
Dim str_SQL as String = "SELECT Data.dID, Data.dName, Data.dPic FROM Data ORDER BY Data.dID DESC"
Dim LogoCmd As New OleDbCommand(str_SQL, sConn)
Dim fs As FileStream 'Writes the Blob to a file(*.bmp)
Dim bw As BinaryWriter 'Streams the Binary data to the File Object
Dim bufferSize As Integer = 100 'The Size of the BLOB Buffer
Dim OutByte() As Byte
Dim retval As Long 'The Bytes returned from GetBytes
Dim startIndex As Long 'TheStarting Position from the BLOB output
sConn.Open()
Dim myReader As OleDbDataReader
Try
myReader = LogoCmd.ExecuteReader()
Catch ee As System.Data.OleDb.OleDbException
MessageBox.Show(ee.Message)
End Try
myReader.Read()
lblDBFileName.Text = "File Name:" & myReader.GetValue(1)
fs = New FileStream(txtOpen.Text, FileMode.OpenOrCreate, FileAccess.Write)
bw = New BinaryWriter(fs)
startIndex = 0
OutByte = myReader(2)
bw.Write(OutByte, 0, OutByte.Length)
bw.Flush()
bw.Close()
fs.Close()
myReader.Close()
sConn.Close()
If chkPic.Checked = True Then
LoadPicture(txtOpen.Text)
End If
End Sub
Private Sub LoadPicture(ByVal FileLocation As String)
Dim BM As Bitmap
BM = New Bitmap(BM.FromFile(FileLocation))
PictureBox1.Image = BM
End Sub