Esempio n. 1
0
        public void DeleteRow(JobPortal portal, int id)
        {
            string tableName = portal.ToString();
            string sql = string.Format("DELETE FROM {0} WHERE id={1}", tableName, id);

            _dbConnection.Open();

            SQLiteCommand command = new SQLiteCommand(sql, _dbConnection);
            command.ExecuteNonQuery();

            _dbConnection.Close();
        }
Esempio n. 2
0
        // TODO: try catch
        private bool TableExists(JobPortal table)
        {
            string tableName = table.ToString();
            string sql = string.Format(
                "SELECT count(*) AS count FROM sqlite_master WHERE type='table' AND name='{0}'", tableName);

            _dbConnection.Open();

            SQLiteCommand command = new SQLiteCommand(sql, _dbConnection);
            SQLiteDataReader reader = command.ExecuteReader();

            long count = 0;
            while (reader.Read())
            {
                count = (long)reader["count"];
            }

            _dbConnection.Close();

            return count == 1;
        }
Esempio n. 3
0
        // TODO: try catch
        private void CreateTable(JobPortal table)
        {
            Logger.LogStart(Logger.MethodName);

            string tableName = table.ToString();

            string columnsDefinition = CreateColumnsDefinition();

            string sql = string.Format(
                "CREATE TABLE {0} (" +
                    "Id INTEGER PRIMARY KEY NOT NULL, " +
                    "DateTime TEXT NOT NULL, " +
                    "{1})", tableName, columnsDefinition);

            _dbConnection.Open();

            SQLiteCommand command = new SQLiteCommand(sql, _dbConnection);

            command.ExecuteNonQuery();

            Logger.LogInfo(string.Format("Tabel '{0}' created.", table));

            _dbConnection.Close();

            Logger.LogStop(Logger.MethodName);
        }