Esempio n. 1
0
        private void loadItemsFromDB()
        {
            // UsernameBox.Items.Clear();
            foreach (string database in globalvariables.DatabaseLocations)
            {
                using (SQLiteConnection sqlite_connection = new SQLiteConnection("Data Source=" + database + ";Version=3;"))
                {
                    sqlite_connection.Open();

                    string sql = "select V_Key,Stig_Name,System_Name,entryID,transactionID,commentText,userID from Comments;";
                    using (SQLiteCommand command = new SQLiteCommand(sql, sqlite_connection))
                    {
                        using (SQLiteDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                CommentEntry ce = new CommentEntry();
                                ce.Comment = (string)reader["commentText"];
                                ce.UserID  = reader["userID"] as string ?? "";
                                if (!UserAccounts.Contains(reader["userID"] as string))
                                {
                                    UserAccounts.Add(reader["userID"] as string);
                                }
                                ce.TransactionID = reader["transactionID"] as string ?? "";
                                ce.EntryID       = reader["entryID"] as string ?? "";
                                ce.System_Name   = reader["System_Name"] as string ?? "";
                                ce.Stig_Name     = reader["Stig_Name"] as string ?? "";
                                ce.V_Key         = reader["V_Key"] as string ?? "";
                                Comments.Add(ce);
                            }
                            reader.Close();
                            sqlite_connection.Close();
                            command.Dispose();
                        }
                    }
                }
            }
        }