Bonjour,
Je code un petit programme en C# utilisant Sqlite.
Seulement, ma requête paramétrée avec un select me rend un résultat étrange selon ma compréhension.
Code c# : 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 //Define connexion variable string DbPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"DB\"); string DbName = ConfigurationManager.AppSettings["dbName"]; string DbConnexion = ConfigurationManager.AppSettings["dbConnexion"]; string DbPassword = ConfigurationManager.AppSettings["dbPassword"]; Int32 fieldcount = 0; //define connexion string conn = (ConfigurationManager.ConnectionStrings[DbConnexion].ToString().Replace(@"$dbPath", DbPath)).Replace("$dbName", DbName); //sql string string sqlQuery = @"SELECT @p0 FROM clients;"; //create connexion and open it SQLiteConnection conex = new SQLiteConnection(conn); conex.Open(); //create sqlite command SQLiteCommand cmd = conex.CreateCommand(); cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; //add parameters cmd.Parameters.AddWithValue("@p0", "clients.*"); //prepare command //cmd.Prepare(); //execute query SQLiteDataReader sqlreader = cmd.ExecuteReader(); //output result while (sqlreader.Read()) { fieldcount++; Console.WriteLine(fieldcount+" --- "+sqlreader[0]); //Console.WriteLine("{0}",sqlreader["id_client"]); } //close sql read sqlreader.Close(); //close connexion conex.Close();
Normalement, si je comprend bien la doc sqlite, je devrais avoir un tableau (reader) avec le contenu complet de ma table client.
Sauf qu'il me rend
C'est à dire qu'il rend autant de fois clients.* que j'ai d'enregistrements dans la table clients.
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 1 --- clients.* 2 --- clients.* 3 --- clients.* 4 --- clients.* 5 --- clients.* 6 --- clients.* 7 --- clients.* 8 --- clients.* 9 --- clients.* 10 --- clients.* 11 --- clients.* 12 --- clients.* 13 --- clients.* 14 --- clients.* 15 --- clients.* 16 --- clients.* 17 --- clients.* 18 --- clients.* 19 --- clients.* 20 --- clients.* 21 --- clients.* 22 --- clients.* 23 --- clients.* 24 --- clients.* 25 --- clients.* 26 --- clients.* 27 --- clients.* 28 --- clients.* 29 --- clients.* 30 --- clients.* 31 --- clients.* 32 --- clients.* 33 --- clients.* 34 --- clients.* 35 --- clients.* 36 --- clients.* 37 --- clients.* 38 --- clients.* 39 --- clients.* 40 --- clients.* 41 --- clients.* 42 --- clients.* 43 --- clients.* 44 --- clients.*
Une idée ou explication sur le concepts de paramètres qu'il me semble avoir mal compris.
Merci.
Partager