Android Question Error

DevSrOscar

New Member
Hola amiguitos tengo una duda como puedo imprimir imágenes desde una base de datos en SQLite
este es mi código:
Public Sub SelectOneImagen(Id As Int) As Bitmap
Dim cursor As Cursor
' Dim data As Mascota
' data.Initialize()
cursor = Sql.ExecQuery2("SELECT Image FROM IMG WHERE ID = ?", Array As String(Id))
If cursor.RowCount > 0 Then
cursor.Position = 0
Dim ImageData() As Byte
ImageData = cursor.GetBlob("Image")

' Convierte el array de bytes en un Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(ImageData, 0, ImageData.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
In.Close
Log("Se encontró la imagen con ID " & Id)
cursor.Close
Return bmp
Else
cursor.Close
Log("No se encontró la imagen con ID " & Id)
Return Null
End If
' cursor.Position = 0
' Dim ImageData() As Byte
' ImageData = cursor.GetBlob("Image")
'
' Dim In As InputStream
' In.InitializeFromBytesArray(ImageData, 0, ImageData)
' Dim bmp As Bitmap
' bmp.Initialize(In)
' In.Close

' Return bmp
End Sub
me sale este error cada que lo ejecuto:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 71 (Mascotas)
android.database.sqlite.SQLiteException: no such table: IMG (code 1 SQLITE_ERROR[1]): , while compiling: SELECT Image FROM IMG WHERE ID = ?
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1521)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:957)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:63)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:2254)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:2193)
at anywheresoftware.b4a.sql.SQL.ExecQuery2(SQL.java:223)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
 
Top