Bonsoir
je vient de d'essayer de combiner Unity avec Sqlite, j'ai créer ma base manuellement avec Sqlite Browser et j'ai ajouté un table à la base .
quand j'essaye de se connecter à la base à partir de Unity ça marche mais quand je veut récupérer les valeurs de la table un erreur survient disant
pourtant que le table est déja là, la configuration est bien faite. les DLLs sont en place, en faite j'ai suivi ce Tuto http://answers.unity3d.com/questions...for-unity.html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 SqliteException: SQLite error no such table: banane Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain) Mono.Data.Sqlite.SqliteCommand.BuildNextCommand ()
Voici mon code
j'ai naviguer sur le net pour trouver la solution mais tout est ambigue ^^
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 using UnityEngine; using System.Collections; using System.Data; //using Mono.Data.SqliteClient; using Mono.Data.Sqlite; using System; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start () { string conn = "URI=file:db.db"; //Path to database. IDbConnection dbconn; dbconn = (IDbConnection) new SqliteConnection(conn); Debug.Log ("avant"); dbconn.Open(); //Open connection to the database. Debug.Log ("aprés"); IDbCommand dbcmd = dbconn.CreateCommand(); string sqlQuery = "SELECT calories from banane"; dbcmd.CommandText = sqlQuery; IDataReader reader = dbcmd.ExecuteReader(); while (reader.Read()) { Debug.Log("kk"); int calories = reader.GetInt16(0); Debug.Log( "calories"+ calories); } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; } // Update is called once per frame void Update () { } }
PS: 'utilise C# comme langage
y'a t-il des propositions ?
Partager