So when I run this query in in sqliteBrowser:
select Peer_guid from State where file_md5 = '0C-B3-E7-B9-.....'"
I get 'B' as return value and this is correct.
But, when I run the same query with C# like this:
string sql = String.Format("select Peer_guid from State where file_md5 = '{0}'", md5);
List<string> guids = new List<string>();
try
{
using (SQLiteConnection c = new SQLiteConnection(ConnectionString))
{
c.Open();
using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
{
SQLiteDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string guid = (string)reader["Peer_guid"];
guids.Add(guid);
}
reader.Close();
reader.Dispose();
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error ({0}): {1}", ex.Message, ex.StackTrace);
logFile.WriteErrorLog(ex.ToString());
return null;
}
return guids;
The string guid becomes: 'Ɣ', not 'B'
It seems the query is correct and the casting to string does not work. How do I get the right value?
Aucun commentaire:
Enregistrer un commentaire