Hope Everyone is fine,
Just having a problem with SQL Blob code.
I'M using EZCamera code to initialize Device Camera.
I'm using SQL Tutorial Code for InserBlob & ReadBlob.
Now im having problem when I try to Read the image from SQL.
Any Suggestion will be very helpful.
Pls find my code and also Error Message as below:
The code Stop at This Line in Debug Mode: Bitmap1.Initialize2(InputStream1)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
100
** Activity (main) Pause, UserClosed = false **
** Activity (update_delivery) Create, isFirst = true **
true
** Activity (update_delivery) Resume **
1434556800000
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
(Cursor) Not initialized
ExecuteMemoryTable: SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
(SQLiteCursor) android.database.sqlite.SQLiteCursor@21dbec20
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
0
[Ljava.lang.String;@21dbf210
net.garstangs.ezcamera.EZcamera@21dc72b0
** Activity (update_delivery) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
DO: S11
S11
** Activity (update_delivery) Resume **
UPDATE DeliveryRegister Set Status = '' WHERE DONumber = 'S11'
1434556800000
18/06/2015
INSERT INTO DeliveryUpdate VALUES (Null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
(SQLiteCursor) android.database.sqlite.SQLiteCursor@21e38ca8
Error occurred on line: 1438 (update_delivery)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$2.onLongClick(ViewWrapper.java:87)
at android.view.View.performLongClick(View.java:4428)
at android.widget.TextView.performLongClick(TextView.java:8572)
at android.view.View$CheckForLongPress.run(View.java:18135)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5406)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Just having a problem with SQL Blob code.
I'M using EZCamera code to initialize Device Camera.
I'm using SQL Tutorial Code for InserBlob & ReadBlob.
Now im having problem when I try to Read the image from SQL.
Any Suggestion will be very helpful.
Pls find my code and also Error Message as below:
The code Stop at This Line in Debug Mode: Bitmap1.Initialize2(InputStream1)
B4X:
Sub InsertBlob
'convert the image file to a bytes array
Dim InputStream1 As InputStream
'cam.TakePicture(File.DirDefaultExternal, "" &Pnl6Lbl2DO_no.Text& ".jpg")
InputStream1 = File.OpenInput(File.DirRootExternal, "" &Pnl5EdtTxt1PoDo_no.Text& ".jpg")
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
File.Copy2(InputStream1, OutputStream1)
Dim Buffer() As Byte 'declares an empty array
Buffer = OutputStream1.ToBytesArray
'Log(Buffer)
Log(Pnl6Lbl2DO_no.Text)
'write the image to the database
Log(Pnl5EdtTxt1PoDo_no.Text)
SQL2.ExecNonQuery2("UPDATE " &DBTableNameupdate& " SET " &ColNames2(12)& " = ? WHERE " &ColNames2(1)& " = ?", Array As Object(Buffer, "'" &Pnl5EdtTxt1PoDo_no.Text& "'")
End Sub
'Using a Cursor.GetBlob we fetch the previously stored image.
'Now we are using an input stream that reads from this Array AND load the image
Sub ReadBlob
Dim Cursor1 As Cursor
'Using ExecQuery2 is safer as it escapes special characters automatically.
'In this case it doesn't really matter.
Cursor1 = SQL2.ExecQuery2("SELECT image FROM " & DBTableNameupdate & " WHERE " &ColNames2(12)& " = ?", Array As String("'"&Pnl6Lbl2DO_no.Text&"';"))
'Cursor1 = SQL2.ExecQuery("SELECT " &ColNames2(12)& " FROM " & DBTableNameupdate & " WHERE " &ColNames2(12)& " = '" &Pnl5EdtTxt1PoDo_no.Text& "'")
Log(Cursor1)
Cursor1.Position = 0
Dim Buffer() As Byte 'declare an empty byte array
Buffer = Cursor1.GetBlob(ColNames2(12))
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, 1)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1)
InputStream1.Close
Activity.SetBackgroundImage(Bitmap1)
End Sub
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
100
** Activity (main) Pause, UserClosed = false **
** Activity (update_delivery) Create, isFirst = true **
true
** Activity (update_delivery) Resume **
1434556800000
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
(Cursor) Not initialized
ExecuteMemoryTable: SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
(SQLiteCursor) android.database.sqlite.SQLiteCursor@21dbec20
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
SELECT ID,DONumber,DODate,DOReceiveDate, DeliveryAddress, DeliveryDate, OutletName FROM DeliveryRegister WHERE DONumber = 'S11'
0
[Ljava.lang.String;@21dbf210
net.garstangs.ezcamera.EZcamera@21dc72b0
** Activity (update_delivery) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
DO: S11
S11
** Activity (update_delivery) Resume **
UPDATE DeliveryRegister Set Status = '' WHERE DONumber = 'S11'
1434556800000
18/06/2015
INSERT INTO DeliveryUpdate VALUES (Null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
(SQLiteCursor) android.database.sqlite.SQLiteCursor@21e38ca8
Error occurred on line: 1438 (update_delivery)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$2.onLongClick(ViewWrapper.java:87)
at android.view.View.performLongClick(View.java:4428)
at android.widget.TextView.performLongClick(TextView.java:8572)
at android.view.View$CheckForLongPress.run(View.java:18135)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5406)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)