locked
Retrieving BLOB from database into Bitmap image problem? Please help me RRS feed

  • Question

  • User-1538122812 posted

    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 .

    Wednesday, November 7, 2012 6:27 AM

All replies

  • User1943143334 posted

    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...

    Thursday, November 8, 2012 12:28 AM
  • User-1538122812 posted

    Thx for ur help, but I already have that code, but I need to find what throws this exception.

    Sunday, November 11, 2012 5:52 AM
  • User1943143334 posted

    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...

    Thursday, November 15, 2012 11:44 PM
  • User-1538122812 posted

    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!

    Tuesday, November 20, 2012 2:13 AM