SQL BLOB problem

Discussion in 'Questions (Windows Mobile)' started by HARRY, May 8, 2007.

  1. HARRY

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

    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:
    Code:
    Sub Globals
        
    dim blob(0as 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.
     
  3. HARRY

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

    Erel Administrator Staff Member Licensed User

    I've attached the example.
    Make sure you are working with the updated SQL libraries.
     

    Attached Files:

  5. HARRY

    HARRY Active Member Licensed User

    Erel,

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

    Harry
     
  6. 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
     
  7. Erel

    Erel Administrator Staff Member Licensed User

  8. 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
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    I've checked the program I've send you on the device and it works properly.
    If you want you can send me your code.
     
  10. 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
     
Loading...