I am building a mobile application using vb.net with an oracle 11g mobile server .
I am storing a client's signature in a BLOB in the database. I want to show the signature on interface as a bitmap image.
I have used the following code , but it gives me an exception :
Private Sub LoadPod()
Dim dsn As String = "dsn=PDA_OLITE_PUB;uid=aa;pwd=bb"
conn = New Oracle.DataAccess.Lite.OracleConnection(dsn)
cmdSel = New OracleCommand
cmdSel = conn.CreateCommand
Dim sql As String = "SELECT delevn_sign , delevn_date, delvnt_no ,sig_blob FROM trk_delivery_events WHERE delevn_status='OK' and delvnt_no='" & tracking.DeliveryNo & "'"
conn.Open()
cmdSel.CommandText = sql
cmdSel.Connection = conn
cmdSel.Prepare()
Dim SQLreader As IDataReader
SQLreader = cmdSel.ExecuteReader()
While SQLreader.Read()
txtRecipientName.Text = SQLreader.GetString(0)
txtPODdatetime.Text = SQLreader.GetString(1)
Dim bytes As OracleBlob
bytes = (SQLreader.GetValue(3))
Dim byteArr As Byte() = New Byte(bytes.Length - 1) {}
Dim mStream As System.IO.MemoryStream
mStream = New System.IO.MemoryStream()
Dim pData() As Byte = DirectCast(byteArr, Byte())
mStream.Write(pData, 0, Convert.ToInt32(pData.Length))
Dim bm As Bitmap
bm = New Bitmap(mStream)
pbRecSig.Image = bm
End While
cmdSel.Dispose()
conn.Close()
End Sub
This is the part where the exception occurs : " bm = New Bitmap(mStream) "
It gives " out of memory exception "
What's wrong with that code? Any ideas? Please help me guys
moe_caruso
Member
9 Points
41 Posts
Retrieving BLOB from database into Bitmap image problem? Please help me
Nov 07, 2012 10:27 AM|LINK
Hello ,
I am building a mobile application using vb.net with an oracle 11g mobile server .
I am storing a client's signature in a BLOB in the database. I want to show the signature on interface as a bitmap image.
I have used the following code , but it gives me an exception :
Private Sub LoadPod()
Dim dsn As String = "dsn=PDA_OLITE_PUB;uid=aa;pwd=bb"
conn = New Oracle.DataAccess.Lite.OracleConnection(dsn)
cmdSel = New OracleCommand
cmdSel = conn.CreateCommand
Dim sql As String = "SELECT delevn_sign , delevn_date, delvnt_no ,sig_blob FROM trk_delivery_events WHERE delevn_status='OK' and delvnt_no='" & tracking.DeliveryNo & "'"
conn.Open()
cmdSel.CommandText = sql
cmdSel.Connection = conn
cmdSel.Prepare()
Dim SQLreader As IDataReader
SQLreader = cmdSel.ExecuteReader()
While SQLreader.Read()
txtRecipientName.Text = SQLreader.GetString(0)
txtPODdatetime.Text = SQLreader.GetString(1)
Dim bytes As OracleBlob
bytes = (SQLreader.GetValue(3))
Dim byteArr As Byte() = New Byte(bytes.Length - 1) {}
Dim mStream As System.IO.MemoryStream
mStream = New System.IO.MemoryStream()
Dim pData() As Byte = DirectCast(byteArr, Byte())
mStream.Write(pData, 0, Convert.ToInt32(pData.Length))
Dim bm As Bitmap
bm = New Bitmap(mStream)
pbRecSig.Image = bm
End While
cmdSel.Dispose()
conn.Close()
End Sub
This is the part where the exception occurs : " bm = New Bitmap(mStream) "
It gives " out of memory exception "
What's wrong with that code? Any ideas? Please help me guys
Thank you in advance .
roopeshreddy
All-Star
20143 Points
3327 Posts
Re: Retrieving BLOB from database into Bitmap image problem? Please help me
Nov 08, 2012 04:28 AM|LINK
Hi,
It totally depends on how you store the data in the BLOB!
They way you store the data in BLOB, you should be retrieve in similar way!
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
moe_caruso
Member
9 Points
41 Posts
Re: Retrieving BLOB from database into Bitmap image problem? Please help me
Nov 11, 2012 09:52 AM|LINK
Thx for ur help, but I already have that code, but I need to find what throws this exception.
roopeshreddy
All-Star
20143 Points
3327 Posts
Re: Retrieving BLOB from database into Bitmap image problem? Please help me
Nov 16, 2012 03:44 AM|LINK
Hi,
Did you tried debugging the code?
Moreover, you can catch the OutOfMemory exception and analyze it!
http://www.dotnetperls.com/outofmemoryexception
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
moe_caruso
Member
9 Points
41 Posts
Re: Retrieving BLOB from database into Bitmap image problem? Please help me
Nov 20, 2012 06:13 AM|LINK
Yes, I debugged the code. I know where the exception occurs, but I can't determine what's wrong. I have searched a lot,but I didn't get a solution!