Storing & Retrieving Images in SQL Mobile

Tech-Archive recommends: Fix windows errors by optimizing your registry



I am trying to take a picture from a PDA and then store that picture in SQL
Mobile which I have done, but when I try to retrieve the picture I get an
out of memory error. I'm not sure I'm storing it correctly though, do I
need to do some sort of compression on it first? I'm using VS 2005 and
merge replication. Thanks, below is my code:

'TO STORE THE IMAGE

Dim fs As New FileStream(strDirectory & "\" & strFileName, FileMode.Open,
FileAccess.Read)
Dim img As Byte() = New Byte(fs.Length) {}
Dim prm As New SqlCeParameter
prm.SqlDbType = SqlDbType.Image
prm.Size = img.Length
prm.Value = img

Me._cmd.CommandText = "Update Employee Set EmployeePic=? Where
EmployeeId=1194"
Me._cmd.Parameters.Clear()
Me._cmd.Parameters.Add(prm)
Me._cmd.ExecuteNonQuery()

fs = Nothing
img = Nothing
prm = Nothing



'TO RETRIEVE THE IMAGE, CODE FAILS ON
DIM BMP WITH OUT OF MEMORY

Dim img As Image
Dim sqlce As SqlCeDataReader
sqlce = globals.gDB.GetEmployeePic(1194)

Try
Dim byt As Byte()
While sqlce.Read
byt = sqlce.Item("EmployeePic")
Dim bmp As New Bitmap(New System.IO.MemoryStream(byt))
img = bmp
bmp = Nothing
End While

Me.PictureBox1.Image = img

Catch ex As OutOfMemoryException
MessageBox.Show(ex.Message)
End Try
.



Relevant Pages

  • Re: Print Preview !!!
    ... Visio Development Blog ... Public Sub New ... Dim temporaryShape As Microsoft.Office.Interop.Visio.Shape ... ' picture is the size of the page. ...
    (microsoft.public.visio.developer)
  • RE: Programatically insert pictures into a table field
    ... achieve was a high level of evidence integrity, ... If you have a picture control on a form or report, ... The class object is defined with Get & Let properties as well as ... Dim rstCheques As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: insignia tv, a lament and a problem!
    ... > Here I will lament a bit over my tv experiences! ... > discovered, for picture quality. ... > it is very very hard for me to check out the picture in a crowded store ... > I wonder how long this Insignia will last, ...
    (sci.electronics.repair)
  • Re: Need Help With Hyperlink Macro
    ... Dim PicDlg As Dialog ... Dim FName As String ... ' now move insertion point to end of picture just inserted ... the picture itself a hyperlink but rather creates a separate hyperlink line ...
    (microsoft.public.word.vba.general)
  • Re: Need Help With Hyperlink Macro
    ... Dim PicDlg As Dialog ... Dim FName As String ... ' now move insertion point to end of picture just inserted ... the picture itself a hyperlink but rather creates a separate hyperlink line ...
    (microsoft.public.word.vba.general)