private async Task AddRecipesAsync() { var list = await GetAllRecepiesFromHttpRequest(); SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbName); await conn.InsertAllAsync(list); }
public async Task DeleteCounterAsync(Counter counter) { var connection = new SQLiteAsyncConnection(_dbPath); await connection.DeleteAsync(counter); OnCountersChanged(); }
private void AppBarToggleButton_Checked(object sender, RoutedEventArgs e) { AppBarToggleButton favButton = sender as AppBarToggleButton; //if ((bool)favButton.IsChecked) //{ // var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB"; // var con = new SQLiteAsyncConnection(path); // //await con.InsertAllAsync(results); // await con.QueryAsync<Result>(string.Format("insert into Result (name,name) values('{0}','{1}')", results[0].name, tblock.Text)); //} //else //{ //} if ((bool)favButton.IsChecked) { var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB"; var con = new SQLiteAsyncConnection(path); con.QueryAsync<Favourite>(string.Format("insert into Favourite (placeName,userName) values('{0}','{1}')", results[0].name, tblock.Text)); } else if (!(bool)favButton.IsChecked) { var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB"; var con = new SQLiteAsyncConnection(path); con.QueryAsync<Favourite>(string.Format("delete from Favourite where placeName = '{0}' and username='******'", results[0].name, tblock.Text)); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { tblock.Text = !string.IsNullOrEmpty((App.Current as App).NavigateText) ? (App.Current as App).NavigateText : string.Empty; var path = ApplicationData.Current.LocalFolder.Path + "/mydb.db"; var con = new SQLiteAsyncConnection(path); //con.QueryAsync<person>("select name from person where name= ") + ""; //con.UpdateAsync("update person set password='******' where password='******' "); //person p1 = new person(); //List<person> allpersons1 = new List<person>(); //allpersons1 = await con.QueryAsync<person>("select name from person where name=" + "\'" + tblock.Text + "\'"); //if (allpersons1.Count == 1) //{ // p1 = allpersons1[0]; //} //await con.QueryAsync<person>("alter TABLE person add column isConfirmed integer "); if (isAdmin) { users.Visibility = Visibility.Visible; List<person> notConfirmedUsers = await con.QueryAsync<person>("select name from person where isConfirmed = 0"); users.ItemsSource = notConfirmedUsers; } else { users.Visibility = Visibility.Collapsed; } }
public async Task<TrackItem> LoadTrack(int trackId) { var connection = new SQLiteAsyncConnection(DbPath); var query = connection.Table<TrackItem>().Where(x => x.Id.Equals(trackId)); var result = await query.ToListAsync(); return result.FirstOrDefault(); }
public DatabaseDriver(string Path) { this.AsyncConnection = new SQLiteAsyncConnection(Path, true); int err = this.AsyncConnection.ExecuteScalarAsync<int>("PRAGMA journal_mode = MEMORY").Result; _path = Path; Task shuttingTheCompilerWarningUp = InitializeDatabaseAsync(); }
private async void Button_Click_3(object sender, RoutedEventArgs e) { SQLiteAsyncConnection conn = new SQLiteAsyncConnection(ApplicationData.Current.LocalFolder.Path + "\\people.db"); var query = conn.Table<Person>();//.Where(x => x.Name == "张三"); var result = await query.ToListAsync(); listbox.ItemsSource = result; }
public async Task<AlbumItem> LoadAlbumViaName(int artistId, string albumName) { var connection = new SQLiteAsyncConnection(DbPath); var query = connection.Table<AlbumItem>().Where(x => x.Name.Equals(albumName)).Where(x => x.ArtistId == artistId); var result = await query.ToListAsync(); return result.FirstOrDefault(); }
public async Task<string> GetFirstTrackPathByAlbumId(int albumId) { var connection = new SQLiteAsyncConnection(DbPath); var query = connection.Table<TrackItem>().Where(x => x.AlbumId == albumId); var result = await query.FirstOrDefaultAsync(); return result != null ? result.Path : null; }
public async Task <bool> DeleteFromDBAsync(FreeDiscItemDownload freeDiscDownloader) { if (freeDiscDownloader == null) { #if DEBUG Debug.Write("DeleteFromDBAsync: freeDiscDownloader == null"); #endif return(false); } #if DEBUG Debug.Write("DeleteFromDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString()); #endif if (freeDiscDownloader.DBID == 0) { #if DEBUG Debug.Write("DeleteFromDB: freeDiscDownloader.DBID == 0 !"); #endif return(false); } try { var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath); await conn.CreateTableAsync <FreeDiscItemDownload>(); await conn.DeleteAsync(freeDiscDownloader); } catch (Exception e) { #if DEBUG Debug.Write("DeleteFromDB: Delete error ! : " + e.ToString()); #endif return(false); } return(true); }
public async Task <bool> SaveToDBAsync(FreeDiscItemDownload freeDiscDownloader) { if (freeDiscDownloader == null) { #if DEBUG Debug.Write("SaveToDBAsync: freeDiscDownloader == null"); #endif return(false); } #if DEBUG Debug.Write("SaveToDB: ID" + freeDiscDownloader.DBID + " Title: " + freeDiscDownloader?.Title + " Status: " + freeDiscDownloader?.ItemStatus.ToString()); #endif try { var conn = new SQLite.SQLiteAsyncConnection(App.AppSetting.DBDownloadPath); await conn.CreateTableAsync <FreeDiscItemDownload>(); await conn.InsertAsync(freeDiscDownloader); } catch (Exception e) { #if DEBUG Debug.Write("SaveToDB: Save error !"); #endif return(false); } #if DEBUG Debug.Write("SaveToDB: Result ID" + freeDiscDownloader?.DBID ?? "NULL"); #endif return(true); }
private async void Create() { Connection = new SQLiteAsyncConnection(dbpath); // create all tables Connection.CreateTableAsync<SQLite.Task>(); }
private async void btnOK_Click(object sender, RoutedEventArgs e) { SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true); Person person = new Person { DoctorName = watermarkTextBox.Text, Date = datepick.ValueString, Time = timepick.ValueString }; await conn.InsertAsync(person); //My_Medi.ViewModels.MainViewModel veiw = new ViewModels.MainViewModel(); //veiw.LoadData(); DataContext = App.ViewModel; App.ViewModel.Items.Clear(); App.ViewModel.LoadData(); NavigationService.GoBack(); }
/// <summary> /// For Displaying search result from database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void acbDrugSearch_TextChanged(object sender, RoutedEventArgs e) { var folder = ApplicationData.Current.LocalFolder.GetFolderAsync("DataFolder"); SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "DataFile.sqlite"), true); string pillname = acbDrugSearch.Text; if (!string.IsNullOrEmpty(pillname) && !string.IsNullOrWhiteSpace(pillname) && pillname.Length > 3) { var query = conn.Table<drugs>().Where(x => x.drugname.Contains(pillname)); var result = await query.ToListAsync(); if (result == null) { MessageBox.Show("Pill not found."); } else { List<string> drugnamelist = new List<string>(); foreach (var item in result) { dataReadName =item.drugname; dataReadMilligram = item.strenght; dataReadNameMilligram = dataReadName + dataReadMilligram; drugnamelist.Add(dataReadNameMilligram); } lstDrugSearch.ItemsSource = drugnamelist; } } }
public async Task<int> AddVisit(Visit visit) { SQLiteAsyncConnection conn = new SQLiteAsyncConnection(this.dbPath); if (visit.ID > 0) { return await conn.UpdateAsync(visit); } return await conn.InsertAsync(visit); }
async Task<MusicLibraryViewModel.ArtistItem> LoadViaArtistName(string artistName) { var connection = new SQLiteAsyncConnection(_dbPath); var query = connection.Table<MusicLibraryViewModel.ArtistItem>().Where(x => x.Name.Equals(artistName)); var result = await query.ToListAsync(); return result.FirstOrDefault(); }
/// <summary> /// In deze constructor wordt een nieuwe verbinding gemaakt met de LocalDB /// </summary> public LocalDB() { if (webService == null) webService = new WebserviceRef.PixelAppsWebserviceSoapClient(); if (db == null) db = new SQLiteAsyncConnection(path); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { bool dbExist = await CheckDbAsync("Tips.db3"); if (!dbExist) { await CreateDatabaseAsync(); } SQLiteAsyncConnection conn = new SQLiteAsyncConnection("Tips.db3"); var query = conn.Table<Tips>(); tips = await query.ToListAsync(); string title1res = tips[tips.Count - 1].title1; string title2res = tips[tips.Count - 1].title2; string title3res = tips[tips.Count - 1].title3; string desc1res = tips[tips.Count - 1].desc1; string desc2res = tips[tips.Count - 1].desc2; string desc3res = tips[tips.Count - 1].desc3; Tips l = new Tips { title1 = title1res, title2 = title2res, title3 = title3res, desc1 = desc1res, desc2 = desc2res, desc3 = desc3res }; t.Add(l); TipsList.ItemsSource = t; }
public async static Task<int> CounterSubscribed() { SQLiteAsyncConnection sqlConnection = new SQLiteAsyncConnection(DbHelper.DB_PATH); int counters = await sqlConnection.Table<Counter>().CountAsync(); AppStore.AddValue(Constants.CountersSubscribed, counters.ToString()); return counters; }
public async Task <List <Movie> > GetFavorites() { try { await CreateTable(); var db = new SQLite.SQLiteAsyncConnection(_dbPath); // var db = new SQLiteAsyncConnection(_dbPath); List <Movie> results = await db.QueryAsync <Movie>("Select * FROM Movie"); string logResult = ""; foreach (Movie result in results) { logResult += result.id + "-" + result.title + ","; } Log.Debug("GetFavorites", "Returned " + logResult); return(results); } catch (SQLiteException ex) { Log.Debug("Get Favorites", "Exception " + ex.Message); return(new List <Movie>()); } }
private async void Button_Click_2(object sender, RoutedEventArgs e) { if (baza.Equals("eFiszki")) { baza = "AppData"; } var path = Windows.Storage.ApplicationData.Current.LocalFolder.Path + @"\" + baza + ".sqlite"; var db = new SQLiteAsyncConnection(path); List<UserDefaultDataBase> listadostepnychindekow = await db.QueryAsync<UserDefaultDataBase>("Select Id From UserDefaultDataBase"); if (listadostepnychindekow.Count < 1) { MessageDialog dialog = new MessageDialog(egzamin1zamalokomunikat.Text); await dialog.ShowAsync(); } else { if (toggledynamicsave.IsOn) { dynamicsave = true; //this.Frame.Navigate(typeof(NaukaSlowek)); } else { dynamicsave = false; //this.Frame.Navigate(typeof(naukaslowek2)); } if (toggleentertocheck.IsOn) { pressenter = true; } else { pressenter = false; } if (togglestatistic.IsOn) { statistic = true; } else { statistic = false; } if (togglesmartrandom.IsOn) { smartrandom = true; } else { smartrandom = false; } this.Frame.Navigate(typeof(naukaslowek2)); } }
public async Task<string> ReadMessage(int id) { var connection = new SQLiteAsyncConnection(_databasePath); var message = await connection.Table<Message> ().Where(m => m.Id == id).FirstOrDefaultAsync (); return message?.MessageString ?? "No message stored"; }
private async void btnOK_Click(object sender, RoutedEventArgs e) { SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true); //string[] per = new string[10]; var per=App.ViewModel.Items[index]; per.LineFive = watermarkTextBox.Text; per.Linesix = watermarkTextBox1.Text; per.Lineseven = watermarkTextBox2.Text; per.Lineeight = watermarkTextBox3.Text; Person person = new Person() { ID=per.Lineone, DoctorName=per.Linetwo, Date=per.Linethree, Time=per.LineFour, Temperature=per.LineFive, Bp=per.Linesix, symptoms=per.Lineseven, description=per.Lineeight }; await conn.UpdateAsync(person); NavigationService.GoBack(); }
public SQLiteAsyncConnection GetAsyncConnection() { string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, DBName); var conn = new SQLite.SQLiteAsyncConnection(path, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.SharedCache); return(conn); }
private async void LoadChartContents() { bool dbExist = await CheckDbAsync("ouzen.db3"); if (!dbExist) { await CreateDatabaseAsync(); } // Get personnes SQLiteAsyncConnection conn = new SQLiteAsyncConnection("ouzen.db3"); var query = conn.Table<ouzen>(); ouzen = await query.ToListAsync(); for (int i = 0; i < ouzen.Count; i++) Debug.WriteLine(ouzen[i].date1); // items.Add(new ouzen { Name =q , Value = _random.Next(35, 150) }); ((LineSeries)this.LineChart.Series[0]).ItemsSource = ouzen; ((LineSeries)this.LineChart.Series[0]).DependentRangeAxis = new LinearAxis { Minimum = 35, Maximum = 150, Orientation = AxisOrientation.Y, Interval = 5, ShowGridLines = true }; ((LineSeries)this.LineChart.Series[0]).Refresh(); }
public async Task<VideoItem> GetFromPath(String path) { var conn = new SQLiteAsyncConnection(DbPath); var req = conn.Table<VideoItem>().Where(x => x.Path == path); var res = await req.ToListAsync().ConfigureAwait(false); return res.FirstOrDefault(); }
public Task Update(MapModel map) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _dataSources.Remove(_dataSources.First(source => source.ID.Equals(map.ID))); _dataSources.Add(map); return connection.UpdateAsync(map); }
private static async Task SetValueAsyncInternal(string name, string value, SQLiteAsyncConnection conn) { // if we don't have a connection, assume the system one... if(conn == null) conn = StreetFooRuntime.GetSystemDatabase(); // load an existing value... var setting = await conn.Table<SettingItem>().Where(v => v.Name == name).FirstOrDefaultAsync(); if (setting != null) { // change and update... setting.Value = value; await conn.UpdateAsync(setting); } else { setting = new SettingItem() { Name = name, Value = value }; // save... await conn.InsertAsync(setting); } }
async Task<MusicLibraryViewModel.TrackItem> LoadTrack(int artistId, int albumId, string trackName) { var connection = new SQLiteAsyncConnection(_dbPath); var query = connection.Table<MusicLibraryViewModel.TrackItem>().Where(x => x.Name.Equals(trackName)).Where(x => x.ArtistId == artistId).Where(x => x.AlbumId == albumId); var result = await query.ToListAsync(); return result.FirstOrDefault(); }
private static Task CreateDatabase (SQLiteAsyncConnection connection, CancellationToken cancellationToken) { return Task.Factory.StartNew(() => { //Create the tables var createTask = connection.CreateTablesAsync (tableTypes); createTask.Wait(); //Count number of assignments var countTask = connection.Table<Assignment>().CountAsync(); countTask.Wait(); //If no assignments exist, insert our initial data if (countTask.Result == 0) { var insertTask = connection.InsertAllAsync(TestData.All); //Wait for inserts insertTask.Wait(); //Mark database created initialized = true; } }); }
public StationRepository() { string DbFilePath = Path.Combine( System.Environment.GetFolderPath( System.Environment.SpecialFolder.LocalApplicationData), "NorthWind.db"); Database = new SQLiteAsyncConnection(DbFilePath); Database.CreateTableAsync <Entities.Station>().Wait(); var Station1 = new Data.Entities.Station { ID = 1, Name = "1", Description = "EB - Central", Address = "1", Phone = "2739293", Lat = "1", Lng = "1" }; var Station2 = new Data.Entities.Station { ID = 2, Name = "2", Description = "EB - Chapinero", Address = "2", Phone = "2839475", Lat = "2", Lng = "2" }; var Station3 = new Data.Entities.Station { ID = 3, Name = "3", Description = "EB - Restrepo", Address = "3", Phone = "8938495", Lat = "3", Lng = "3" }; var Station4 = new Data.Entities.Station { ID = 4, Name = "4", Description = "EB - Las Ferias", Address = "4", Phone = "1267384", Lat = "4", Lng = "4" }; CreateStationAsync(Station1); CreateStationAsync(Station2); CreateStationAsync(Station3); CreateStationAsync(Station4); }
private async void loadData() { //SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true); SQLiteAsyncConnection conn = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true); conn.DropTableAsync<SampleAppointment>(); await conn.CreateTableAsync<SampleAppointment>(); DateTime temp = DateTime.Now; DateTime start = DateTime.Parse("06/08/2013 6:00 PM"); DateTime end = DateTime.Parse("06/09/2013 6:00 PM"); SampleAppointment appointment1 = new SampleAppointment { Subject = "MACF - App Camp", AdditionalInfo = "BRTN 291, RSVP Reguired", StartDate = start, EndDate = end }; conn.InsertAsync(appointment1); SampleAppointment appointment2 = new SampleAppointment { StartDate = DateTime.Now.AddMinutes(30), EndDate = DateTime.Now.AddHours(1), Subject = "Appointment 376", AdditionalInfo = "Info 3" }; conn.InsertAsync(appointment2); start = DateTime.Parse("06/05/2013 5:00 PM"); end = DateTime.Parse("06/05/2013 6:00 PM"); SampleAppointment appointment3 = new SampleAppointment { StartDate = DateTime.Now.AddHours(2), EndDate = DateTime.Now.AddHours(3), Subject = "Appointment uhy4", AdditionalInfo = "Info 4" }; conn.InsertAsync(appointment3); SampleAppointment appointment4 = new SampleAppointment { Subject = "Malaysian Night", AdditionalInfo = "STEW Common, Members Only", StartDate = start, EndDate = end }; conn.InsertAsync(appointment4); //this.OnDataLoaded(); }
/// <summary> /// Implementing method that creates SQLite connection /// </summary> /// <param name="DB">Database name.</param> /// <returns>DB connection of <seealso cref="SQLiteAsyncConnection"/> type.</returns> public SQLiteAsyncConnection Connection(string DB) { string DocumentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string Path = System.IO.Path.Combine(DocumentsPath, DB); SQLiteAsyncConnection conn = new SQLite.SQLiteAsyncConnection(Path); return(conn); }
/// <summary> /// UWP implementation for creating SQLite connection. /// </summary> /// <param name="DB">Database name.</param> /// <returns>DB connection of <seealso cref="SQLiteAsyncConnection"/> type.</returns> public SQLiteAsyncConnection Connection(string DB) { string LibraryPath = ApplicationData.Current.LocalCacheFolder.Path; string Path = System.IO.Path.Combine(LibraryPath, DB); SQLiteAsyncConnection conn = new SQLite.SQLiteAsyncConnection(Path); return(conn); }
public SQLiteAsyncConnection GetConnection() { var fileName = "database.db3"; var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, fileName); var conn = new SQLite.SQLiteAsyncConnection(path); return(conn); }
public DatabaseDriver(string Path) { this.AsyncConnection = new SQLiteAsyncConnection(Path, true); int err = this.AsyncConnection.ExecuteScalarAsync <int>("PRAGMA journal_mode = MEMORY").Result; _path = Path; Task shuttingTheCompilerWarningUp = InitializeDatabaseAsync(); }
public UserInfoRepository() { string DbFilePath = Path.Combine( System.Environment.GetFolderPath( System.Environment.SpecialFolder.LocalApplicationData), "NorthWind.db"); Database = new SQLiteAsyncConnection(DbFilePath); Database.CreateTableAsync <Entities.UserInfo>().Wait(); }
public SQLiteAsyncConnection GetConnection() { var dbName = "Config.db3"; var docFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData); var path = Path.Combine(docFolder, dbName); var conn = new SQLite.SQLiteAsyncConnection(path); return(conn); }
public SQLiteAsyncConnection GetConnection() { var fileName = "database.db3"; string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var path = Path.Combine(documentsPath, fileName); var conn = new SQLite.SQLiteAsyncConnection(path); return(conn); }
public async void ConnectionDatabaseAsync() { if (connection == null) { var db = await ApplicationData.Current.RoamingFolder.GetFileAsync("SQLiteDB\\eqstramobility.sqlite"); connection = new SQLite.SQLiteAsyncConnection(db.Path); } }
public SQLiteAsyncConnection GetConnectionAsync() { string docsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var path = Path.Combine(docsPath, SqliteFileName); var conn = new SQLite.SQLiteAsyncConnection(path); return(conn); }
public ProductRepository() { string DbFilePath = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData), "NorthWind.db"); _database = new SQLiteAsyncConnection(DbFilePath); _database.CreateTableAsync <Product>().Wait(); }
public SQLiteAsyncConnection GetAsyncConnection() { string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder var path = Path.Combine(documentsPath, DATABASE_NAME); // Create the connection var conn = new SQLite.SQLiteAsyncConnection(path); // Return the database connection return(conn); }
public SQLiteAsyncConnection GetAsyncConnection() { string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder var path = Path.Combine(documentsPath, DBName); // Create the connection var conn = new SQLite.SQLiteAsyncConnection(path, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.SharedCache); // Return the database connection return(conn); }
public SQLiteAsyncConnection GetConnection() { var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); //Se crea la Base de datos var path = Path.Combine(documentsPath, "NorthWind.db"); _database = new SQLiteAsyncConnection(path); _database.CreateTableAsync <Product>().Wait(); return(_database); }
// creating sqlite connection public SQLite.SQLiteAsyncConnection CreateConnection() { var SQLiteFile = "DeepSeaWorldSQLite.db"; string folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string directory = Path.Combine(folder, "..", "Library", "Databases"); string path = Path.Combine(directory, SQLiteFile); var conn = new SQLite.SQLiteAsyncConnection(path); Console.WriteLine("SQLITEAsyncConnection"); return(conn); }
SQLiteAsyncConnection ISQLiteAsync.GetConnectionAsync() { var sqliteFilename = "CR.db"; if (!File.Exists(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "CR.db"))) { Task <bool> task = Task.Run(() => CopyDatabase()); bool result = task.Result; } var conn = new SQLite.SQLiteAsyncConnection(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "CR.db")); return(conn); }
public void CanCreateDatabaseTest() { if (System.IO.File.Exists(Path)) { System.IO.File.Delete(Path); } var conn = new SQLite.SQLiteAsyncConnection(Path); bool exists = System.IO.File.Exists(Path); Assert.AreEqual(true, exists, "Could not generate db"); conn.CloseAsync(); }
public SqliteDatabase( SQLite.SQLiteAsyncConnection connection, bool debug = false ) { Log.Debug("Setup HistoryDatabase with file " + connection.DatabasePath); Connection = connection; _debug = debug; if (_debug) { Connection.Tracer = (s) => Log.Debug(s); Connection.Trace = true; Connection.TimeExecution = true; } }
public void CanCreateDatabaseTest() { if (System.IO.File.Exists(Path)) { System.IO.File.Delete(Path); } SQLitePCL.Batteries_V2.Init(); var db = new SQLite.SQLiteAsyncConnection(Path, true, EncryptionKey); bool exists = System.IO.File.Exists(Path); Assert.AreEqual(true, exists, "Could not generate db"); db.CloseAsync(); }
SQLiteAsyncConnection ISQLiteAsync.GetConnectionAsync() { var sqliteFilename = @"CR.db"; string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var path = Path.Combine(documentsPath, sqliteFilename); if (!File.Exists(path)) { CopyDatabaseIfNotExists(path, sqliteFilename); } // Create the connection var conn = new SQLite.SQLiteAsyncConnection(path); // Return the database connection return(conn); }
public SQLiteDB(LocationEnum dbLocation, string connStr) { mDatabase = new SQLiteAsyncConnection(connStr); switch (dbLocation) { case LocationEnum.Inner: initInnerDB(); break; case LocationEnum.External: initExternalDB(); break; default: initInnerDB(); break; } }
/// <summary> /// Implementing iOS method for creating SQLite connection. /// </summary> /// <param name="DB">Database name.</param> /// <returns>SQLite connection of <seealso cref="SQLiteAsyncConnection"/> type.</returns> public SQLiteAsyncConnection Connection(string DB) { string Path = string.Empty; string DocumentPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string LibraryPath = System.IO.Path.Combine(DocumentPath, "..", "Library", "Databases"); if (!Directory.Exists(LibraryPath)) { Directory.CreateDirectory(LibraryPath); } else { Path = System.IO.Path.Combine(LibraryPath, DB); } SQLiteAsyncConnection conn = new SQLite.SQLiteAsyncConnection(Path); return(conn); }
private async void DeleteTables() { var db = new SQLite.SQLiteAsyncConnection(dbPath); try { db.DropTableAsync <Children>(); db.DropTableAsync <EveryDay>(); db.DropTableAsync <Reminder>(); db.DropTableAsync <Task>(); db.DropTableAsync <Favorite>(); db.DropTableAsync <Contact>(); } catch (System.NullReferenceException e) { } }
public static async Task <SQLiteAsyncConnection> CreateCommDB() { var file = Path.Combine(SDKProperty.dbPath, "common.db"); if (!Directory.Exists(Path.GetDirectoryName(file))) { Directory.CreateDirectory(Path.GetDirectoryName(file)); } //if (!File.Exists(file)) //{ // File.Create(file); //} var comconn = new SQLite.SQLiteAsyncConnection(file); await comconn.CreateTableAsync <DB.historyAccountDB>(); return(comconn); }
public async Task <bool> IsFavorite(string movieid) { try { await CreateTable(); var db = new SQLite.SQLiteAsyncConnection(_dbPath); List <Movie> results = await db.QueryAsync <Movie>("Select _id FROM Movie WHERE _id = " + movieid); Log.Debug("IsFavorite", "movieid '" + movieid + "' returned " + results.Count + "results"); return(results.Count > 0); } catch (SQLiteException ex) { Log.Debug("IsFavorite", "Exception " + ex.Message); return(false); } }
public async System.Threading.Tasks.Task <bool> CreateDB() { SQLite.SQLiteAsyncConnection connection; bool res = await DoesDbExist(textBox.Text); res = true; if (!res) { SQLite.SQLiteOpenFlags sqlflg = SQLite.SQLiteOpenFlags.Create; connection = new SQLite.SQLiteAsyncConnection(textBox.Text, sqlflg, false); } else { connection = new SQLite.SQLiteAsyncConnection(textBox.Text); } await connection.CreateTableAsync <Sensor>(); return(res); }
public static async Task CreateData() { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(DbName); await connection.CreateTableAsync<DataBusLine>(); await connection.CreateTableAsync<DataPoint>(); System.Diagnostics.Debug.WriteLine("Create DB"); }
private void ConnData() { //Creates database if it doesn't exists var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite"); conn = new SQLite.SQLiteAsyncConnection(dbPath); }
private async void enterbtn_Click(object sender, RoutedEventArgs e) { var path = ApplicationData.Current.LocalFolder.Path + "/mydb.db"; var con = new SQLiteAsyncConnection(path); person loginPerson = (await con.QueryAsync<person>("select isConfirmed from person where name='" + Dashboard.userName + "'"))[0]; if (loginPerson.isConfirmed == 1) { List<person> all = new List<person>(); all = await con.QueryAsync<person>("select name,email,country,gender,phone from person where name='" + searchboxtxt.Text + "' AND isConfirmed= 1 "); // var mm1 = new MessageDialog("no matches found").ShowAsync(); String res = ""; foreach (person a in all) { res += "\n\n" + a.name + "\n\n" + a.email + "\n\n" + a.country + "\n\n" + a.gender + "\n\n" + a.phone; } restxtblock.Text = res; } else { var md1 = new MessageDialog("No permission to search for users").ShowAsync(); } }