コード例 #1
0
        public void DatabaseCreate()
        {
            GetConnection();
            _mDbConnection.Open();
            List <string> createTableQueries = new List <string>();

            UserDataManager.CreateTableQueries(createTableQueries);
            BillManager.CreateTableQueries(createTableQueries);

            using (SQLiteTransaction mytransaction = _mDbConnection.BeginTransaction())
            {
                using (SQLiteCommand command = _mDbConnection.CreateCommand())
                {
                    command.Transaction = mytransaction;
                    foreach (string query in createTableQueries)
                    {
                        command.CommandText = query;
                        try
                        {
                            command.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine($@"Error in {query}");
                            Console.WriteLine($@"Message {ex.Message}");
                        }
                    }
                }
                mytransaction.Commit();
            }
            _mDbConnection.Close();
        }