Example #1
0
        public DatabaseError InsertOrUpdateRecord(IDBRecord record)
        {
            ulong val = ulong.Parse(record.GetValueString(record.GetIDQueryValue()));

            if (val == 0)
            {
                InsertRecord(record);
            }
            else
            {
                UpdateRecord(record);
            }
            return(m_ErrorCode);
        }
Example #2
0
 public DatabaseError InsertOrUpdateRecord(IDBCollectionContents contents)
 {
     for (int i = 0; i < contents.Count(); ++i)
     {
         IDBRecord irec = contents.GetRecordInterface(i);
         ulong     val  = ulong.Parse(irec.GetValueString(irec.GetIDQueryValue()));
         if (val == 0)
         {
             InsertRecord(irec);
         }
         else
         {
             UpdateRecord(irec);
         }
     }
     return(m_ErrorCode);
 }
Example #3
0
        public DatabaseError InsertRecord(IDBRecord record)
        {
            m_ErrorCode = DatabaseError.NoError;
            SQLiteCommand sqlite_cmd = (SQLiteCommand)m_conn.CreateCommand();

            try
            {
                sqlite_cmd.CommandText = record.GetDBInsert();
                sqlite_cmd.ExecuteNonQuery();
                sqlite_cmd.CommandText = "SELECT last_insert_rowid();";
                record.SetValueString(record.GetIDQueryValue(), sqlite_cmd.ExecuteScalar());
            }
            catch (System.Data.SQLite.SQLiteException e)
            {
                string msg = e.Message;
                m_ErrorCode = DatabaseError.ExceptionSQL;
            }
            return(m_ErrorCode);
        }