Пример #1
0
 // データを格納する.
 public void AddContent(TAHLocalDbEntry entry)
 {
     using (SQLiteCommand cmd = cnn.CreateCommand())
     {
         // acpathを追加する.
         cmd.CommandText = "INSERT INTO Entry (PATH,DATAID,HASH) VALUES(@path,@id,@hash)";
         cmd.Parameters.AddWithValue("path", entry.path);
         cmd.Parameters.AddWithValue("id", entry.dataid);
         cmd.Parameters.AddWithValue("hash", (int)entry.hash);
         cmd.ExecuteNonQuery();
     }
 }
Пример #2
0
        // エントリを取得する
        public TAHLocalDbEntry GetEntryHash(int hash)
        {
            TAHLocalDbEntry entry = null;

            using (SQLiteCommand cmd = cnn.CreateCommand())
            {
                cmd.CommandText = "SELECT PATH,DATAID,HASH FROM Entry WHERE HASH=@hash";
                cmd.Parameters.AddWithValue("hash", hash.ToString());
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        entry        = new TAHLocalDbEntry();
                        entry.path   = reader[0].ToString();
                        entry.dataid = int.Parse(reader[1].ToString());
                        entry.hash   = int.Parse(reader[2].ToString());
                        break;
                    }
                }
            }
            return(entry);
        }