国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Windows8SQLite數(shù)據(jù)庫操作[Sync]

Windows8SQLite數(shù)據(jù)庫操作[Sync]

(2013-01-22 13:32:03)
標(biāo)簽:

雜談

       private async voidCreateAndOperateSQLiteDataBase()
       {
          //數(shù)據(jù)文件保存的位置
           vardataBasePath =Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,"MSISQLiteDataBase.sqlite");
           //vardataBasePath = Path.Combine(KnownFolders.MusicLibrary.Path,"MSISQLiteDataBase.sqlite");

          //創(chuàng)建或打開數(shù)據(jù)庫
           vardataBase = new SQLite.SQLiteConnection(dataBasePath);
           //vardataBase = new SQLite.SQLiteAsyncConnection(dataBasePath);
          
          //創(chuàng)建表
          dataBase.CreateTable();
           //awaitdataBase.CreateTableAsync();

          //單條插入語句
          dataBase.Insert(new Person() { FirstName = "Jack", LastName ="Slater" });
           //Personperson = new Person(){ FirstName = "Jack", LastName = "Slater"};
           //awaitdataBase.InsertAsync(person);

          //插入操作.首先聲明一個(gè)集合,多條插入集合
          ObservableCollection personCollection = newObservableCollection();
          personCollection.Add(new Person() { FirstName = "Lebron", LastName= "James" });
          personCollection.Add(new Person() { FirstName = "Yao", LastName ="Ming" });
          personCollection.Add(new Person() { FirstName = "Ray", LastName ="Allen" });
           int rows =dataBase.InsertAll(personCollection);
           //int rows= await dataBase.InsertAllAsync(personCollection);

          //更新語句
          //方法1
          SQLiteCommand cmd = dataBase.CreateCommand("update person setFirstName='Jake'where FirstName='Lebron'");
          cmd.ExecuteNonQuery();
          //方法2
          dataBase.Update(new Person() { ID = 2, FirstName = "Yao", LastName= "LiCheng" });
          
           try
           {
              //單行刪除操作
              int pKey = 3;
              dataBase.Delete(pKey);
           }
           catch(Exception ex)
           {
             Debug.WriteLine(ex.Message);
           }

          //多行刪除
          //dataBase.DeleteAll();

          //查詢所有數(shù)據(jù)綁定到UI
          Listlist = dataBase.Query(new TableMapping(typeof(Person)),"select *  from Person");
           //Listlist = await dataBase.QueryAsync("select *  from Person");
          this.listView.ItemsSource = list;

          //dataBase.Dispose();
          //dataBase.Close();
       }

    class Person
    {
      [SQLite.AutoIncrement, SQLite.PrimaryKey]
       public int ID { get; set; }

       public string FirstName { get; set; }

       public string LastName { get; set; }

    }
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
IbatisNet開發(fā)使用小結(jié) 之一
iOS中幾種數(shù)據(jù)持久化方案:我要永遠(yuǎn)地記住你!
JPA的Embeddable Objects - LalfaShi‘Blog
PropertyGrid Refresh problem...
腳本百事通
C# IEnumerable和IEnumerator的區(qū)別,如何實(shí)現(xiàn)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服