I have a sqlite database with table called File, that has a column called FilePath, of type Text.
On that table there is an entry whose FilePath has the value f9a35e24-bce9-46c8-bbc0-02a005455fe3
(the toString of a random GUID).
If I try the following query on SQLiteStudio, it outputs the entry.
SELECT FilePath FROM File WHERE FilePath = 'f9a35e24-bce9-46c8-bbc0-02a005455fe3'
However, using the code below, that uses the System.Data.SQLite
external assembly, it never retrieves the entry.
SQLiteConnection conn = new SQLiteConnection(connectionString);
SQLiteCommand cmd =
new SQLiteCommand(@"SELECT FilePath FROM File WHERE FilePath = '@Where';", conn);
cmd.Parameters.Add("@Where", DbType.String).Value =
"f9a35e24-bce9-46c8-bbc0-02a005455fe3";
conn.Open();
SQLiteDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("not");
}
Am I missing something?
Aucun commentaire:
Enregistrer un commentaire