public void InserindoListaFabricantes(List<Fabricante> fabricantes)
 {
     using (var dbConn = new SQLiteConnection(DB_path))
     {
         dbConn.DropTable<Fabricante>();
         dbConn.Dispose();
         dbConn.Close();
     }
     foreach (Fabricante f in fabricantes)
         this.Inserindo(f);
 }
Пример #2
0
        /**
         * This method is called when the button to delete all stats is clicked
         */
        private async void dropStats(object sender, EventArgs e)
        {
            bool delete = await DisplayAlert("Avertissement", "Attention, supprimer les statistiques est une manoeuvre irréversible !", "Continuer", "Annuler");

            if (!delete)
            {
                return;
            }
            try
            {
                SQLite.SQLiteConnection connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                connection.DropTable <MyPosition>();
                connection.DropTable <Shot>();
                connection.DropTable <ScoreHole>();
                connection.DropTable <ScorePartie>();

                connection.CreateTable <MyPosition>();
                connection.CreateTable <Shot>();
                connection.CreateTable <ScoreHole>();
                connection.CreateTable <ScorePartie>();
            }
            catch (Exception)
            {
            }
        }
Пример #3
0
        private void Seed()
        {
            connection.DropTable <Beer>();
            connection.DropTable <Pub>();

            connection.CreateTable <Beer>();
            connection.CreateTable <Pub>();


            Beers = connection.Table <Beer>();
            Pubs  = connection.Table <Pub>();
        }
Пример #4
0
        public KspMods(string a_InstallationDirectory, string a_ModPath )
        {
            InstallationDirectory = a_InstallationDirectory;
            ModDirectory = a_ModPath;

            db = new SQLiteConnection("kmm.sqlite");

            // make sure the table exists
            if (db.GetTableInfo("KMMInfo").Count == 0)
            {
                db.CreateTable<KMMInfo>();
            }

            var tables = new Type[] { typeof(InstalledMods), typeof(ModFiles), typeof(InstalledFiles) };

            foreach (var table in tables)
            {
                var info = db.GetTableInfo(table.Name);
                if (info.Count == 0)
                    db.CreateTable(table);
            }

            // oh noez it does not match
            if (db.Table<KMMInfo>().Count() == 0 || db.Table<KMMInfo>().First().Version != GetAssemblyVersion())
            {
                // salvage data
                var installed_mods = db.Table<InstalledMods>().ToList();
                db.DropTable<InstalledMods>();
                db.CreateTable<InstalledMods>();
                db.InsertAll(installed_mods);

                var mod_files = db.Table<ModFiles>().ToList();
                db.DropTable<ModFiles>();
                db.CreateTable<ModFiles>();
                db.InsertAll(mod_files);

                var installed_files = db.Table<InstalledFiles>().ToList();
                db.DropTable<InstalledFiles>();
                db.CreateTable<InstalledFiles>();
                db.InsertAll(installed_files);
            }

            // make sure the table is filled
            if (db.Table<KMMInfo>().Count() == 0)
            {
                var nfo = new KMMInfo()
                {
                    Version = GetAssemblyVersion()
                };
                db.Insert(nfo);
            }
        }
Пример #5
0
 static public void createNewsItemTable()
 {
     db.DropTable <NewsItem>();
     db.CreateTable <NewsItem>();
     //db.DropTable
     //return true;
 }
Пример #6
0
 public void Drop()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.DropTable<Account>();
     }
 }
Пример #7
0
 public void Drop()
 {
     using (var db = new SQLiteConnection(DbPath))
     {
         db.DropTable<TracklistItem>();
     }
 }
Пример #8
0
 private void RemoveTableButton_Click(object sender, RoutedEventArgs e)
 {
     using (var connection = new SQLiteConnection(new Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         connection.DropTable <User>();
         this.Users.Clear();
     }
 }
Пример #9
0
 public void DeleteAllScores()
 {
     lock (collisionLock)
     {
         database.DropTable <Scoreboard>();
         database.CreateTable <Scoreboard>();
     }
 }
Пример #10
0
 public static void Exec()
 {
     using (sql.SQLiteConnection connection = new sql.SQLiteConnection("testdb.db"))
     {
         connection.CreateTable(typeof (Table));
         connection.Insert(typeof (A));
         connection.DropTable<Table>();
     }
 }
Пример #11
0
        private void Button_Clicked_1(object sender, EventArgs e)
        {
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                reteta reteta = new reteta();
                conn.DropTable <reteta>();

                DisplayAlert("Succes", "Lista de cumparaturi este stearsa", "OK");
            }
        }
Пример #12
0
		public static void SaveEvents (List<Event> eventsList)
		{
			string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "Event.sqlite");

			var db = new SQLiteConnection (path);

			db.DropTable<Event> ();

			db.CreateTable<Event> ();

			db.InsertAll (eventsList);
		}
        public void Setup()
        {
            _cache.ApplicationName = AppName;

            _expectedDatabasePath = Path.Combine(
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), AppName),
                "SimpleObjectCache");

            Directory.CreateDirectory(_expectedDatabasePath);
            _connection = new SQLiteConnection(Path.Combine(_expectedDatabasePath, "cache.db3"));
            _connection.DropTable<CacheElement>();

        }
Пример #14
0
 private async void drop(object sender, RoutedEventArgs e)
 {
     try
     {
         var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "data.db3");
         using (var db = new SQLite.SQLiteConnection(dbpath))
         {
             db.DropTable <person>();
             db.Dispose();
             db.Close();
         }
         var line = new MessageDialog("Table Dropped");
         await line.ShowAsync();
     }
     catch
     {
     }
 }
Пример #15
0
        public string createDatabase()
        {
            try
            {
                string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                mCon = new SQLiteConnection(System.IO.Path.Combine(folder, "db.db"));
                mCon.DropTable<User>();

                {
                    mCon.CreateTable<User>();
                    return "Database created";
                }
            }
            catch (SQLiteException ex)
            {
                return ex.Message;
            }
        }
Пример #16
0
        //Userテーブルのuserを削除するメソッド
        //--------------------------delete文的なの--------------------------
        public static void deleteUser(int id)
        {
            //データベースに接続
            using (SQLiteConnection db = new SQLiteConnection(App.dbPath))
            {
                //db.BeginTransaction();  //このサイト https://qiita.com/alzybaad/items/9356b5a651603a548278
                try
                {
                    db.CreateTable <UserModel>();
                    db.DropTable <UserModel>();

                    db.Delete(id);
                }
                catch (Exception e)
                {
                    db.Rollback();
                    System.Diagnostics.Debug.WriteLine(e);
                }
            }
        }
Пример #17
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Figure out where the SQLite database will be.
			var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			_pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

			using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))
			{
				conn.DropTable<Terms>();
				conn.CreateTable<Terms>();
			}

			btnAceptar.TouchUpInside += (sender, e) => {
				insertTerms();
				NavigationController.PopViewController(true);
			};

			btnCancelar.TouchUpInside += (sender, e) => NavigationController.PopViewController (true);
		}
Пример #18
0
        protected void saveProfileImage(string image)
        {
            ProfileImage profileImage = new ProfileImage();

            profileImage.Base64 = image;
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.FilePath))
            {
                conn.DropTable <ProfileImage>();

                conn.CreateTable <ProfileImage>();

                int rowsAdded = conn.Insert(profileImage);
                if (rowsAdded > 0)
                {
                    Debug.WriteLine("Inserted Itinerary");
                }
                else
                {
                    Debug.WriteLine("Failed to Insert Itinerary");
                }
                conn.Close();
            }
        }
 public void DropTable() => connection.DropTable <Product>();
Пример #20
0
 //Delete all contactlist or delete Contacts table 
 public void DeleteAllContact()
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         //dbConn.RunInTransaction(() => 
         //   { 
         dbConn.DropTable<GhiChu>();
         dbConn.CreateTable<GhiChu>();
         dbConn.Dispose();
         dbConn.Close();
         //}); 
     }
 }
Пример #21
0
 static void DropTables()
 {
     _db.DropTable <Sprayer>();
     _db.DropTable <Operator>();
     _db.DropTable <OrchardBlock>();
 }
Пример #22
0
 //~~~delete all activities
 public void DeleteActivities ()
 {
     using (var dbConn = new SQLiteConnection(this.KreyosDBPath))
     {
         //dbConn.RunInTransaction(() => 
         //   { 
         dbConn.DropTable<Kreyos_User_Activities>();
         dbConn.CreateTable<Kreyos_User_Activities>();
         dbConn.Dispose();
         dbConn.Close();
         //}); 
     }
 } 
Пример #23
0
 static public void dropNewsItemTable()
 {
     db.DropTable <NewsItem>();
 }
 public void CrearBBDD()
 {
     cn.DropTable <Secciones>();
     cn.CreateTable <Secciones>();
 }
 }//DELETE CONTACT THAT I CHOSE
 //DELETE ALL
 public void DeleteAllContact()
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         dbConn.DropTable<Contactos>();
         dbConn.CreateTable<Contactos>();
         dbConn.Dispose();
         dbConn.Close();
     }
 }
Пример #26
0
 //테이블 전체 삭제 및 재생성
 public bool AllTableDrop()
 {
     bool result = false;
     try
     {
         //DB Connection
         SQLiteConnection conn = new SQLiteConnection(dbPath, true);
         //테이블 삭제
         conn.DropTable<DBForm.MoneyDBForm>();
         conn.DropTable<DBForm.ExpenseCategoryForm>();
         conn.DropTable<DBForm.IncomeCategoryForm>();
         //연결종료
         conn.Close();
         //새로 테이블을 만든다.
         CreateDatabaseAsync();
         //카테고리 새로 세팅
         BasicSetting();
         //어플리케이션종료하기위해 결과 값을 리턴한다.
         result = true;
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
         result = false;
     }
     return result;
 }
Пример #27
0
		public static void Main (string[] args)
		{
			Console.WriteLine ("Hello SQLite-net Data!");

			/*
			//Get the path to the folder where the database is stored.
			// Notes: The Path class performs operations on strings that contain file path info
			//        Path.Combine appends the second path to the first path
			//        Environment.GetSpecialFolderPath gets the path to special pre-defined folders
			//              on Windows, the SpecialFolder enum defines: ProgramFiles, System, AppData, etc.
			//              on Android ...
			string dbPath = Path.Combine (
				Environment.GetFolderPath (Environment.SpecialFolder.Personal), "stocks.db3");
			*/

			/*
			// Check for an existing db file and only create a new one if it doesn't exist
			bool exists = File.Exists (dbPath);
			if (!exists) {
				// Need to create the database and seed it with some data.
				SQLiteConnection.CreateFile (dbPath);
			*/

			// We're using a file in Assets instead of the one defined above
			//string dbPath = Directory.GetCurrentDirectory ();
			string dbPath = @"../../../DataAccess-Android/Assets/stocks.db3";
			var db = new SQLiteConnection (dbPath);

			// Create a Stocks table
			//if (db.CreateTable (Mono.CSharp.TypeOf(Stock)) != 0) 
				db.DropTable<Stock>();
			if (db.CreateTable<Stock>() == 0)
			{
				// A table already exixts, delete any data it contains
				db.DeleteAll<Stock> ();
			}

			// Create a new stock and insert it into the database
			var newStock = new Stock ();
			newStock.Symbol = "APPL";
			newStock.Name = "Apple";
			newStock.ClosingPrice = 93.22m;
			int numRows = db.Insert (newStock);
			Console.WriteLine ("Number of rows inserted = {0}", numRows);

			// Insert some more stocks
				db.Insert(new Stock() {Symbol = "MSFT", Name = "Microsoft", ClosingPrice = 55.25m});
				db.Insert (new Stock() {Symbol = "GOOG", Name = "Google", ClosingPrice = 15.25m});
				db.Insert (new Stock() {Symbol = "SSNLF", Name = "Samsung", ClosingPrice = 25.25m});
				db.Insert (new Stock() {Symbol = "AMZN", Name = "Amazon", ClosingPrice = 35.25m});
				db.Insert (new Stock() {Symbol = "MMI", Name = "Motorola Mobility", ClosingPrice = 45.25m});
				db.Insert (new Stock() {Symbol = "FB", Name = "Facebook", ClosingPrice = 65.25m});

			// Read the stock from the database
			// Use the Get method with a query expression
			Stock singleItem = db.Get<Stock> (x => x.Name == "Google");
			Console.WriteLine ("Stock Symbol for Google: {0}", singleItem.Symbol);

			singleItem = db.Get<Stock> (x => x.ClosingPrice >= 30.0m);
				Console.WriteLine ("First stock priced at or over 30: {0}, price: {1}",
									singleItem.Symbol, singleItem.ClosingPrice);
			

				// Use the Get method with a primary key
			singleItem = db.Get<Stock> ("FB");
			Console.WriteLine ("Stock Name for Symbol FB: {0}", singleItem.Symbol);

			// Query using  SQL
			var stocksStartingWithA = db.Query<Stock> ("SELECT * FROM Stocks WHERE Symbol LIKE ?", "A%"); 
			foreach(Stock stock in stocksStartingWithA)
				Console.WriteLine ("Stock starting with A: {0}", stock.Symbol);

			// Query using Linq
			var stocksStartingWithM = from s in db.Table<Stock> () where s.Symbol.StartsWith ("M") select s;
			foreach(Stock stock in stocksStartingWithM)
				Console.WriteLine ("Stock starting with M: {0}", stock.Symbol);


		}
Пример #28
0
		public async Task ClearDatabase ()
		{
			using (var connection = new SQLiteConnection (dbPath, true))
				await Task.Run (() => connection.DropTable<BikeTrip> ()).ConfigureAwait (false);
		}
Пример #29
-1
 /// <summary>
 /// Delete the Alarm entity table.
 /// </summary>
 public void DeleteAllAlarmEntities()
 {
     lock(DbLock)
     {
         using (var db = new SQLiteConnection(DatabaseHelper.GetDBPath()))
         {
             db.DropTable<AlarmEntities>();
         }
     }
 }