예제 #1
0
        public bool Insert(dataColumn column)
        {
            using (var connection = new SQLiteConnection(_connectionString))
            {
                int           res     = -1;
                SQLiteCommand command = new SQLiteCommand(null, connection);
                try
                {
                    connection.Open();
                    command.CommandText = $"INSERT INTO {tableName} ({dataColumn.columnBoardId},{dataColumn.columnOrdinal},{dataColumn.columnLimit},{dataColumn.columnName}) " +
                                          $"VALUES (@columnBoardId,@columnOrdinal,@columnLimit,@columnName);";


                    SQLiteParameter boardIdParam = new SQLiteParameter(@"columnBoardId", column.boardId);
                    SQLiteParameter ordinalParam = new SQLiteParameter(@"@columnOrdinal", column.ordinal);
                    SQLiteParameter nameParam    = new SQLiteParameter(@"columnName", column.name);
                    SQLiteParameter limitParam   = new SQLiteParameter(@"columnLimit", column.limit);

                    command.Parameters.Add(boardIdParam);
                    command.Parameters.Add(ordinalParam);
                    command.Parameters.Add(nameParam);
                    command.Parameters.Add(limitParam);
                    command.Prepare();

                    res = command.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    log.Warn(e.ToString());
                    log.Warn("Insert failed");
                }
                finally
                {
                    command.Dispose();
                    connection.Close();
                }
                return(res > 0);
            }
        }// insert new column to database according to the dataColumn fields
예제 #2
0
        }// insert new column to database according to the dataColumn fields

        protected override dal ConvertReaderToObject(SQLiteDataReader reader) // reading from DB and create DataColumn Object
        {
            dataColumn result = new dataColumn(Convert.ToInt32(reader.GetValue(0)), Convert.ToInt32(reader.GetValue(1)), Convert.ToInt32(reader.GetValue(2)), reader.GetString(3));

            return(result);
        }