Salut,

En utilisant la ref System.Data.SQLite j arrive a me connecter a ma SQLite database, ainsi que lire les données qui ne sont pas des blobs. Mais j ai un probleme pour la lecture de blob ...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
Dim dbFile As String
        dbFile = "C:\Copy of Network_NEW_HP.db "
 
        Dim SQLconnect As New SQLite.SQLiteConnection()
        SQLconnect.ConnectionString = "Data Source=" & dbFile & ";"
        SQLconnect.Open()
 
        Dim SQLcommand1 As SQLiteCommand
        SQLcommand1 = SQLconnect.CreateCommand
 
        SQLcommand1.CommandText = "SELECT * FROM nodeattributes where node_id=2 and attribute_id=66"
 
        Dim SQLreader1 As SQLiteDataReader = SQLcommand1.ExecuteReader()
        While SQLreader1.Read()
            Dim node_id As Integer = SQLreader1(0)
            Dim attribute_id As Integer = SQLreader1(1)
            Dim mStream As New System.IO.MemoryStream
            Dim pData() As Byte = DirectCast(SQLreader1(2), Byte())
            'Dim bm(,) As Double = Convert.ToDouble(pData)
            'mStream.Dispose()
 
            Console.WriteLine(node_id & vbTab & attribute_id)
            Console.WriteLine(pData)
 
        End While
 
        SQLcommand1.Dispose()
        SQLconnect.Close()
Je suppose que le blob doit etre lu comme un vecteur de byte (voir la variable pData dans le code ci-dessus, mais je n arrive pas a comprendre comment convertir c bytes en un tableau de valeurs.

Je ne sais pas si ca va aider a comprendre mon probleme, mais par exemple en python la solution pour lire mon blob serait :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
import sqlalchemy.types
import sqlite3
import sqlalchemy
import pickle
 
cnx = sqlite3.connect("C:/Copy of Network_NEW_HP.db")
cur = cnx.cursor()
cur.execute("""SELECT * FROM nodeattributes where node_id=2 and attribute_id=66""")
blob = cur.fetchone()[2]
if blob !=None:
    v= pickle.loads(str(blob))
    print v
Ce qui me retourne le resultat :

[[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]
[ 50.]]
Mais voila, je voudrais pouvoir faire de meme en vb.net ...

J espere que quelqu un saura m aider

Merci

Slumpy