i have problem when save image use MS Access Database.
field name is pict -> OLE OBJECT

hire my code when save image :
vb.net Code:
  1. 'simpan file gambar
  2.             Dim img As Image = ucPhoto.getGambar
  3.  
  4.  
  5.             If img IsNot Nothing Then
  6.  
  7.                 Dim imgPar As New OleDbParameter
  8.                 Dim fs As FileStream
  9.                 Dim sfname As String = ucPhoto.FileName
  10.  
  11.                 fs = New FileStream(sfname, FileMode.Open, FileAccess.Read)
  12.                 Dim picByte As Byte() = New Byte(CInt(fs.Length - 1)) {}
  13.  
  14.                 fs.Read(picByte, 0, System.Convert.ToInt32(fs.Length))
  15.  
  16.                 fs.Close()
  17.  
  18.  
  19.                 imgPar.OleDbType = OleDbType.Binary
  20.                 imgPar.ParameterName = "pict"
  21.                 imgPar.Value = picByte
  22.  
  23.             End If

when i run that code is not problem. but when i run code to display image i get error:
vb.net Code:
  1. If dr.Item("pict") IsNot Nothing Then
  2.                     Dim fsImage As New IO.FileStream("img.jpg", IO.FileMode.Create)
  3.                     Dim blob As Byte() = DirectCast(dr.Item("pict"), Byte())
  4.  
  5.                     fsImage.Write(blob, 0, blob.Length)
  6.                     fsImage.Close()
  7.                     fsImage = Nothing
  8.  
  9.                     ucPhoto.setImage(Image.FromFile("img.jpg"))
  10.  
  11.                 End If

error at line :
Code:
Dim blob As Byte() = DirectCast(dr.Item("gambar"), Byte())
error message :
Code:
Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'
thank you