SQL BLOB problem

HARRY

Active Member
Licensed User
Erel,

Still, I do not succeed to read a BLOB. The coding I use is as indicated by you:

Dim blob(0) as Byte

Sub Button4_Click
Cmd.CommandText = "SELECT * FROM WPOILABEL_V1"
Reader.Value = Cmd.ExecuteReader
Do While Reader.ReadNextRow = TRUE
blob() = Reader.GetBytes(4)
Label1.Text=blob()
'Do what you need with the bytes array.
Loop
Reader.Close
End Sub

On the line blob() = etc. I get the message:Input string was not in a correct format.

According to SQLite Expert column 4 ( and 5) are blobs and do contain information.

The data base concerned is UTF-16le encoded. I have attached the data base.

Any idea what is going wrong?

Harry
 

Erel

Administrator
Staff member
Licensed User
The problem is with this line:
Label1.text = blob()

blob() is an array of bytes. You can't assign it directly as a string.
See this code:
B4X:
Sub Globals
    dim blob(0) as byte
End Sub

Sub App_Start
    con.New1
    con.Open("Data Source = " & AppPath & "\igo.db")
    cmd.New1("SELECT * FROM WPOILABEL_V1", con.Value)
    Reader.New1
    reader.Value = cmd.ExecuteReader
    Reader.ReadNextRow
    blob() = reader.GetBytes(4)
    for i = 0 to ArrayLen(blob()) - 1
        textBox1.Text = textBox1.Text & blob(i)  & ","
    next
    form1.Show
    reader.Close
End Sub
You could use the Bitwise library to convert it to hex values.
I'm not sure what is stored in the BLOB columns and in what format. You will need to check it.
 

HARRY

Active Member
Licensed User
Erel,


Sorry, but the problem is really in the line:

blob() = reader.GetBytes(4)

The error message is : Input string was not in a correct format.

If I remove all further coding the error remains.

I do not know what is meant with 'input string': the BLOB itself or the code line as input to the SQL process or to .NET?

Harry
 

HARRY

Active Member
Licensed User
Erel,

Thanks and sorry! The old dll's were still in the application path!

Harry
 

HARRY

Active Member
Licensed User
Erel,

I was too optimistic. The example you sent me works fine on the desktop. But on the PDA I get the message: "Error loading program. \Programmabestanden\Basic4PPC-programma's\test\SQLDevice.dll."

SQLDevice.dll really is in the path indicated. It's version is 1.0.2656.38193.

The same problem occurs with my own program.

Am I again doing something wrong?

Harry
 

HARRY

Active Member
Licensed User
Erel,

There is progress again and also the next problem/question. The program starts and the data base is opened. However, when the following statements are executed its is reported that there is no such table: WPOILABEL_V1:

Cmd.CommandText = "SELECT * FROM WPOILABEL_V1"
Reader.Value = Cmd.ExecuteReader

That table really exists!

On the desk top everything works fine. The data base is UTF-16le encoded(!).

Do you understand the different behaviour and do you have a solution?

Harry
 

HARRY

Active Member
Licensed User
Erel,

Finally I got it running. It was due to one or more small coding errors I made. I have the impression that SQLite on the DeskTop is more forgiving than SQLite on the PDA. Therefore debugging was difficult; it did run on the DeskTop and not on the PDA.

Thanks for your help.

Harry
 
Top