• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SQLite.SQLiteConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SQLite.SQLiteConnection的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection类的具体用法?C# SQLiteConnection怎么用?C# SQLiteConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SQLiteConnection类属于SQLite命名空间,在下文中一共展示了SQLiteConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Drop

 public void Drop()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.DropTable<Account>();
     }
 }
开发者ID:FLKone,项目名称:HFR4WinRT,代码行数:7,代码来源:AccountDataRepository.cs


示例2: BasicSetting

 //기본 카테고리 생성
 public void BasicSetting()
 {
     try
     {
         //DB와 연결
         SQLiteConnection conn = new SQLiteConnection(dbPath, true);
         //기본 카테고리들 생성
         string[] basicIncomeCategory = { "Salary", "Interest", "Installment Saving", "Allowance" };
         string[] basicExpenseCategory = { "Electronics", "Food", "Internet", "Transport", "Housing" };
         //돌아가면서 Income category insert
         foreach (string tempCategory in basicIncomeCategory)
         {
             IncomeCategoryForm basicCategory = new IncomeCategoryForm
             {
                 categoryName = tempCategory
             };
             conn.Insert(basicCategory);
         }
         //돌아가면서 expense category insert
         foreach (string tempCategory in basicExpenseCategory)
         {
             ExpenseCategoryForm expenseCategory = new ExpenseCategoryForm
             {
                 categoryName = tempCategory
             };
             conn.Insert(expenseCategory);
         }
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
     }
 }
开发者ID:sviom,项目名称:MoneyNote,代码行数:34,代码来源:SQLiteMethods.cs


示例3: GetLastLocation

 private async Task<Location> GetLastLocation()
 {
     using (var db = new SQLiteConnection(Database.DatabasePath))
     {
         return db.Table<Location>().OrderByDescending(x => x.Timestamp).FirstOrDefault();
     }
 }
开发者ID:peterdn,项目名称:Geomoir,代码行数:7,代码来源:MainPage.xaml.cs


示例4: CheckAuth

		public static async Task<Exception> CheckAuth(string id, string pass,SQLiteConnection connection)
		{
			pass = base64Encode (pass);
			var httpClient = new HttpClient ();
			Exception  error;
			httpClient.Timeout = TimeSpan.FromSeconds (20);
			string contents;
			Task<string> contentsTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/dangnhap/"+id+"/"+pass);

			try
			{
				contents =  await contentsTask;

			}
			catch(Exception e) {
				error =new Exception("Xảy Ra Lỗi Trong Quá Trình Kết Nối Server");
				return error;
			}
			if (contents.Contains ("false")) {
				error=new Exception("Mã Sinh Viên Hoặc Mật Khẩu Không Đúng");
				return error;

			}
			User usr = new User ();
			usr.Password = pass;
			usr.Id = id;
			Task<string> contentNameTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/user/" + id);
			contents=await contentNameTask;
			XDocument doc = XDocument.Parse (contents);
			usr.Hoten= doc.Root.Elements().ElementAt(0).Elements().ElementAt(1).Value.ToString();
			int i = AddUser (connection, usr);
			return null;
		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:33,代码来源:BUser.cs


示例5: Initialize

 public void Initialize()
 {
     using (var db = new SQLiteConnection(DbPath))
     {
         db.CreateTable<TracklistItem>();
     }
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:7,代码来源:TracklistItemDatabase.cs


示例6: InsertPost

 public void InsertPost(Post post)
 {
     using(Connection = new SQLiteConnection(this.DbPath))
     {
         this.Connection.Insert(post);
     }
 }
开发者ID:CodeTrainerFormation,项目名称:WindowsPhone,代码行数:7,代码来源:PostHelper.cs


示例7: getAll

			public static List<DiemThi> getAll(SQLiteConnection connection)
			{
				list = new List<DiemThi>();
				DataProvider dtb = new DataProvider (connection);
				list = dtb.GetAllDT ();
				return list;
			}
开发者ID:tienbui123,项目名称:School-App-Mobile,代码行数:7,代码来源:BDiemThi.cs


示例8: AddCategoryOffline

        public bool AddCategoryOffline(CategoryOfflineViewModel newCategoryOffline, string _synced)
        {
            bool result = false;
            try
            {
                using (var db = new SQLite.SQLiteConnection(_dbPath))
                {
                    CategoryOffline objCategoryOffline = new CategoryOffline();

                    objCategoryOffline.categoryId = Convert.ToString(newCategoryOffline.categoryId);
                    objCategoryOffline.organizationId = Convert.ToString(newCategoryOffline.organizationId);
                    objCategoryOffline.categoryCode = Convert.ToString(newCategoryOffline.categoryCode);
                    objCategoryOffline.categoryDescription = newCategoryOffline.categoryDescription;
                    objCategoryOffline.parentCategoryId = newCategoryOffline.parentCategoryId;
                    objCategoryOffline.imageName = newCategoryOffline.imageName;
                    objCategoryOffline.active = newCategoryOffline.active;

                    objCategoryOffline.synced = _synced;  // i.e. Need to synced when online and Update the synced status = "True"

                    db.RunInTransaction(() =>
                    {
                        db.Insert(objCategoryOffline);
                    });
                }

                result = true;
            }//try
            catch (Exception ex)
            {

            }//catch
            return result;
        }
开发者ID:neetajoshi1908,项目名称:PointPay,代码行数:33,代码来源:CategoryDataProvider.cs


示例9: DoSomeDataAccess

		/// <returns>
		/// Output of test query
		/// </returns>
		public static string DoSomeDataAccess ()
		{
			var output = "";
			output += "\nCreating database, if it doesn't already exist";
			string dbPath = Path.Combine (
				Environment.GetFolderPath (Environment.SpecialFolder.Personal), "ormdemo.db3");

			var db = new SQLiteConnection (dbPath);
			db.CreateTable<Stock> ();

			if (db.Table<Stock> ().Count() == 0) {
				// only insert the data if it doesn't already exist
				var newStock = new Stock ();
				newStock.Symbol = "AAPL";
				db.Insert (newStock); 

				newStock = new Stock ();
				newStock.Symbol = "GOOG";
				db.Insert (newStock); 

				newStock = new Stock ();
				newStock.Symbol = "MSFT";
				db.Insert (newStock);
			}

			output += "\nReading data using Orm";
			var table = db.Table<Stock> ();
			foreach (var s in table) {
				output += "\n" + s.Id + " " + s.Symbol;
			}

			return output;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:36,代码来源:OrmExample.cs


示例10: ProcessPath

        public static void ProcessPath(string databasePath, string filePath)
        {
            //TODO ensure directory exists for the database
            using (var db = new SQLiteConnection(databasePath)) {

                DatabaseLookups.CreateTables(db);

                var hdCollection = DriveUtilities.ProcessDriveList(db);

                var start = DateTime.Now;

                List<string> arrHeaders = DriveUtilities.GetFileAttributeList(db);

                var directory = new DirectoryInfo(filePath);

                var driveLetter = directory.FullName.Substring(0, 1);
                //TODO line it up with the size or the serial number since we will have removable drives.
                var drive = hdCollection.FirstOrDefault(letter => letter.DriveLetter.Equals(driveLetter, StringComparison.OrdinalIgnoreCase));

                if (directory.Exists) {
                    ProcessFolder(db, drive, arrHeaders, directory);
                }

                //just in case something blew up and it is not committed.
                if (db.IsInTransaction) {
                    db.Commit();
                }

                db.Close();
            }
        }
开发者ID:joefeser,项目名称:WhereAreMyFiles,代码行数:31,代码来源:FileDataStore.cs


示例11: Update

 public void Update(Account currentAccount)
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.Update(currentAccount);
     }
 }
开发者ID:FLKone,项目名称:HFR4WinRT,代码行数:7,代码来源:AccountDataRepository.cs


示例12: Initialize

 public void Initialize()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.CreateTable<Account>();
     }
 }
开发者ID:FLKone,项目名称:HFR4WinRT,代码行数:7,代码来源:AccountDataRepository.cs


示例13: GetAccounts

 public List<Account> GetAccounts()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         return connection.Table<Account>().ToList();
     }
 }
开发者ID:FLKone,项目名称:HFR4WinRT,代码行数:7,代码来源:AccountDataRepository.cs


示例14: CreateDatabase

        /// <summary>
        /// Creates the database if it doesn't already exist.
        /// </summary>
        internal static void CreateDatabase()
        {
            try
            {
                if (!File.Exists(IndexLocation))
                {
                    string absolutePath = HostingEnvironment.MapPath(VirtualCachePath);

                    if (absolutePath != null)
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(absolutePath);

                        if (!directoryInfo.Exists)
                        {
                            // Create the directory.
                            Directory.CreateDirectory(absolutePath);
                        }
                    }

                    using (SQLiteConnection connection = new SQLiteConnection(IndexLocation))
                    {
                        connection.CreateTable<CachedImage>();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:hputtick,项目名称:ImageProcessor,代码行数:33,代码来源:SQLContext.cs


示例15: SaveLTRemind

		public static void SaveLTRemind(SQLiteConnection connection,LTRemindItem item)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLTRemind (item.MaMH, item.NamHoc, item.HocKy) == null) {
				dtb.AddRemindLT (item);
			}
		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:7,代码来源:BRemind.cs


示例16: Create

 public static void Create()
 {
     Console.WriteLine ("Creo Database...");
     string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "cust.db");
     var db = new SQLiteConnection (dbPath);
     db.CreateTable<schede> ();
 }
开发者ID:frungillo,项目名称:vegetha,代码行数:7,代码来源:scheda.cs


示例17: SaveLHRemind

		public static void SaveLHRemind(SQLiteConnection connection,LHRemindItem item)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLHRemind (item.IDLH,item.Date) == null) {
				dtb.AddRemindLH (item);
			}
		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:7,代码来源:BRemind.cs


示例18: MainModel

        public MainModel()
        {
            // This forces the instantiation
            mDictionarySearcher = ServiceContainer.Resolve<SearchModel> ();
            mSuggestionModel = ServiceContainer.Resolve<SuggestionModel> ();
            mPlaySoundModel = ServiceContainer.Resolve<PlaySoundModel> ();

            mDictionarySearcher.SearchCompleted += OnSearchCompleted;

            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            mDatabasePath = Path.Combine(documentsPath, "..", "Library", "db_sqlite-net.db");

            bool isFirstLoad = false;

            using (var conn = new SQLite.SQLiteConnection(mDatabasePath))
            {
                // https://github.com/praeclarum/sqlite-net/wiki
                // In general, it will execute an automatic migration
                conn.CreateTable<WordModel>();
                conn.CreateTable<WaveModel>();

                InitialRefresh(conn);
                LoadNextWord(conn);
                RefreshWordsList(conn);

                isFirstLoad = conn.Table<WordModel>().Count() == 0;
            }

            if (isFirstLoad)
            {
                AddWord("Thanks");
                AddWord("For");
                AddWord("Downloading");
            }
        }
开发者ID:vmendi,项目名称:ListenAndRepeat,代码行数:35,代码来源:MainModel.cs


示例19: Connect

        public void Connect()
        {
            sqlConnection = new SQLiteConnection(DB_PATH);

            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey(DB_VERSION_KEY))
            {
                ApplicationData.Current.LocalSettings.Values.Add(DB_VERSION_KEY, 0);
            }

            int currentDatabaseVersion = DebugHelper.CastAndAssert<int>(ApplicationData.Current.LocalSettings.Values[DB_VERSION_KEY]);

            if (currentDatabaseVersion < 1)
            {
                sqlConnection.CreateTable<ArtistTable>();
                sqlConnection.CreateTable<AlbumTable>();
                sqlConnection.CreateTable<SongTable>();
                sqlConnection.CreateTable<PlayQueueEntryTable>();
                sqlConnection.CreateTable<PlaylistTable>();
                sqlConnection.CreateTable<PlaylistEntryTable>();
                sqlConnection.CreateTable<HistoryTable>();
                sqlConnection.CreateTable<MixTable>();
                sqlConnection.CreateTable<MixEntryTable>();
            }

            if (currentDatabaseVersion < DB_VERSION)
            {
                ApplicationData.Current.LocalSettings.Values[DB_VERSION_KEY] = DB_VERSION;
            }
        }
开发者ID:Davidblkx,项目名称:musicmink,代码行数:29,代码来源:DatabaseManager.cs


示例20: IsLogined

		public static bool IsLogined(SQLiteConnection connection)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetMainUser () != null)
				return true;
			return false;
		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:7,代码来源:BUser.cs



注:本文中的SQLite.SQLiteConnection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tests.TestDb类代码示例发布时间:2022-05-26
下一篇:
C# SQLite.SQLiteAsyncConnection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap