I've been searching and trying numerous codes to get this done but to no avail. I simply want to load an image binary from SQL CE to be displayed on a picturebox and it should be in VB.NET. Here's the code I'm stuck with

Dim ItemID As Integer = 10814950
Dim SQL As String
Dim BA As Byte()
Dim SC As New SqlCeCommand
SQL = "SELECT ip_img FROM InventoryPhoto WHERE inventory_item_it_id = " & ItemID

SC.Connection = conn
conn.ConnectionString = data_source
SC.Connection.Open()
SC.CommandType = Data.CommandType.Text
SC.CommandText = SQL
BA = CType(SC.ExecuteScalar(), Byte())
SC.Connection.Close()
SC.Dispose()

Dim ArraySize As New Integer
ArraySize = BA.GetUpperBound(0)
Dim fs As New FileStream("tmp.gif", FileMode.CreateNew)

fs.Write(BA, 0, ArraySize + 1)
fs.Close()

PicBox.SizeMode = PictureBoxSizeMode.StretchImage
PicBox.Image = New Bitmap("tmp.gif")

When I execute this, there will be an error pointing to this line -> fs.Write(BA, 0, ArraySize + 1), with the message : Value does not fall within the expected range. Plz help