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

C# SQLitePCL.SQLiteConnection类代码示例

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

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



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

示例1: AddDownload

        public static void AddDownload(string filename,string path, string date, string size)
        {
            string path1 = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "User.db");

            try
            {
                using (var connection = new SQLiteConnection(path1))
                {
                    using (var statement = connection.Prepare(@"INSERT INTO DownloadList (FILENAME,PATH,DATE,SIZE)
                                    VALUES(?,?,?,?);"))
                    {
                       
                        statement.Bind(1, filename);
                        statement.Bind(2, path);
                        statement.Bind(3, date);
                        statement.Bind(4, size);
                    
                        // Inserts data.
                        statement.Step();
                       
                        statement.Reset();
                        statement.ClearBindings();
                        Debug.WriteLine("Download Added");
                    }
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception\n" + ex.ToString());
            }
        }
开发者ID:mtwn105,项目名称:PDFMe-Windows-10,代码行数:32,代码来源:DatabaseController.cs


示例2: getDownloads

        public static ObservableCollection<Downloads> getDownloads()
        {
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "User.db");

            ObservableCollection<Downloads> list = new ObservableCollection<Downloads>();

            using (var connection = new SQLiteConnection(path))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM DownloadList;"))
                {

                    while (statement.Step() == SQLiteResult.ROW)
                    {

                        list.Add(new Downloads()
                        {
                            FileName = (string)statement[0],
                            Path = (string)statement[1],
                            Date = (string)statement[2],
                            Size = (string)statement[3]

                          
                        });

                        Debug.WriteLine(statement[0] + " ---" + statement[1] + " ---" + statement[2]);
                    }
                }
            }
            return list;
        }
开发者ID:mtwn105,项目名称:PDFMe-Windows-10,代码行数:30,代码来源:DatabaseController.cs


示例3: EnableForeignKeys

		private void EnableForeignKeys(SQLiteConnection connection)
		{
			using (var statement = connection.Prepare(@"PRAGMA foreign_keys = ON;"))
			{
				statement.Step();
			}
		}
开发者ID:valeronm,项目名称:handyNews,代码行数:7,代码来源:LocalStorageManager.cs


示例4: SqliteInitializationTest

        public void SqliteInitializationTest()
        {
            string dbPath = Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, DB_FILE_NAME);

            using (SQLiteLocalStorage storage = new SQLiteLocalStorage())
            { }

            using (SQLiteConnection connection = new SQLiteConnection(dbPath))
            {

                var query = "SELECT name FROM sqlite_master WHERE type='table'";
                var tableName = new List<string>();

                using (var sqliteStatement = connection.Prepare(query))
                {
                    while(sqliteStatement.Step() == SQLiteResult.ROW)
                    {
                        tableName.Add(sqliteStatement.GetText(0));
                    }
                }

                Assert.IsTrue(tableName.Count == 2);
                Assert.IsTrue(tableName.Contains("datasets"));
                Assert.IsTrue(tableName.Contains("records")); 
            }
        }
开发者ID:lawandeneel,项目名称:Fashion,代码行数:26,代码来源:SQLiteLocalStorageTests.cs


示例5: LoadDatabase

        public static void LoadDatabase(SQLiteConnection db)
        {
            string sql = @"CREATE TABLE IF NOT EXISTS
                                Customer (Id      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                            Name    VARCHAR( 140 ),
                                            City    VARCHAR( 140 ),
                                            Contact VARCHAR( 140 ) 
                            );";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            sql = @"CREATE TABLE IF NOT EXISTS
                                Project (Id          INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                                         CustomerId  INTEGER,
                                         Name        VARCHAR( 140 ),
                                         Description VARCHAR( 140 ),
                                         DueDate     DATETIME,
                                         FOREIGN KEY(CustomerId) REFERENCES Customer(Id) ON DELETE CASCADE 
                            )";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }

            // Turn on Foreign Key constraints
            sql = @"PRAGMA foreign_keys = ON";
            using (var statement = db.Prepare(sql))
            {
                statement.Step();
            }
        }
开发者ID:MuffPotter,项目名称:201505-MVA,代码行数:33,代码来源:CreateDatabase.cs


示例6: insertData

        public static void insertData(string param1, string param2, string param3)
        {
            try 
            { 
            using (var connection = new SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"INSERT INTO Student (ID,NAME,CGPA)
                                            VALUES(?, ?,?);"))
                {
                    statement.Bind(1, param1);
                    statement.Bind(2, param2);
                    statement.Bind(3, param3);

                    // Inserts data.
                    statement.Step();

                  
                    statement.Reset();
                    statement.ClearBindings();


                }
            }

            }
            catch(Exception ex)
            {
                Debug.WriteLine("Exception\n"+ex.ToString());
            }
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:30,代码来源:DataBaseController.cs


示例7: getValues

        public static ObservableCollection<Student> getValues()
        {
             ObservableCollection<Student> list = new ObservableCollection<Student>();

            using (var connection = new SQLiteConnection("Storage.db"))
            {
                using (var statement = connection.Prepare(@"SELECT * FROM Student;"))
                {
                    
                    while (statement.Step() == SQLiteResult.ROW)
                    {
 
                        list.Add(new Student()
                        {
                            Id = (string)statement[0],
                            Name = (string)statement[1],
                            Cgpa = statement[2].ToString()
                        });

                        Debug.WriteLine(statement[0]+" ---"+statement[1]+" ---"+statement[2]);
                    }
                }
            }
            return list;
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:25,代码来源:DataBaseController.cs


示例8: WordListDB

 public WordListDB()
 {
     connection_ = new SQLiteConnection(DB_NAME);
     using (var statement = connection_.Prepare(SQL_CREATE_TABLE))
     {
         statement.Step();
     }
 }
开发者ID:ZYY1995,项目名称:Database-OF,代码行数:8,代码来源:WordListDB.cs


示例9: PlanetaDao

 public PlanetaDao(SQLiteConnection con)
 {
     this.con = con;
     string sql = "CREATE TABLE IF NOT EXISTS planeta (id INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, gravedad FLOAT)";
     using (var statement =con.Prepare(sql)) {
         statement.Step();
     }
 }
开发者ID:milo2005,项目名称:W10_Persistencia,代码行数:8,代码来源:PlanetaDao.cs


示例10: DBHelper

        private DBHelper(string sqliteDb)
        {
            SoupNameToTableNamesMap = new Dictionary<string, string>();
            SoupNameToIndexSpecsMap = new Dictionary<string, IndexSpec[]>();
            DatabasePath = sqliteDb;
            _sqlConnection = (SQLiteConnection) Activator.CreateInstance(_sqliteConnectionType, sqliteDb);

        }
开发者ID:jhsfdc,项目名称:SalesforceMobileSDK-Windows,代码行数:8,代码来源:DBHelper.cs


示例11: AddFacturaPage

 public AddFacturaPage()
 {
     this.InitializeComponent();
     con = new SQLiteConnection(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "FacturasBD.sqlite"));
     factDao = new FacturaDao(con);
     rootFrame = Window.Current.Content as Frame;
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
     SystemNavigationManager.GetForCurrentView().BackRequested += AddFacturaPage_BackRequested;
 }
开发者ID:dapintounicauca,项目名称:AppFacturas,代码行数:9,代码来源:AddFacturaPage.xaml.cs


示例12: WordBookDB

 public WordBookDB()
 {
     mutex_ = new object();
     connection_ = new SQLiteConnection(SQL_CREATE_TABLE);
     using (var statement = connection_.Prepare(SQL_CREATE_TABLE))
     {
         statement.Step();
     }
 }
开发者ID:ZYY1995,项目名称:Database-OF,代码行数:9,代码来源:WordBookDB.cs


示例13: MainPage

        public MainPage()
        {
            this.InitializeComponent();
            con = new SQLiteConnection(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "FacturasBD.sqlite"));
            factDao = new FacturaDao(con);
            facturas = App.Current.Resources["facturas"] as Facturas;
            rootFrame = Window.Current.Content as Frame;

        }
开发者ID:dapintounicauca,项目名称:AppFacturas,代码行数:9,代码来源:MainPage.xaml.cs


示例14: MobileServiceSQLiteStore

        /// <summary>
        /// Initializes a new instance of <see cref="MobileServiceSQLiteStore"/>
        /// </summary>
        /// <param name="fileName">Name of the local SQLite database file.</param>
        public MobileServiceSQLiteStore(string fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            this.connection = new SQLiteConnection(fileName);
        }
开发者ID:brettsam,项目名称:azure-mobile-apps-net-client,代码行数:13,代码来源:MobileServiceSQLiteStore.cs


示例15: FacturaDao

 public FacturaDao(SQLiteConnection con)
 {
     this.con = con;
     string sql = "CREATE TABLE IF NOT EXISTS factura (id INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, vence DATETIME, alarma DATETIME, valor INTEGER, estado TEXT)";
     using (var statement = con.Prepare(sql))
     {
         statement.Step();
     }
 }
开发者ID:dapintounicauca,项目名称:AppFacturas,代码行数:9,代码来源:FacturaDao.cs


示例16: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            conn = new SQLiteConnection("bazadanych-sqlite.db");
            CreateDatabase.LoadDatabase(conn);

            // Windows 10 Mobile StatusBar Configuration
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
                //statusBar.BackgroundColor = Windows.UI.Colors.Black;
                //statusBar.ForegroundColor = Windows.UI.Colors.White;
                //statusBar.BackgroundOpacity = 1;
                await statusBar.HideAsync();
                
            }


            //await CreateDatabase.ResetDataAsync(conn);
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (Window.Current.Content == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                _rootFrame = new Frame();
                _rootFrame.NavigationFailed += OnNavigationFailed;
                _rootFrame.Navigated += OnNavigated;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = new Shell(_rootFrame);

                // Register a handler for BackRequested events and set the
                // visibility of the Back button
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                    _rootFrame.CanGoBack ?
                    AppViewBackButtonVisibility.Visible :
                    AppViewBackButtonVisibility.Collapsed;

            }

            if (_rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                _rootFrame.Navigate(typeof(Views.MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
开发者ID:pkozak2,项目名称:CeneoETL-Projekt,代码行数:61,代码来源:App.xaml.cs


示例17: BulkInsertSqliteOperation

        public BulkInsertSqliteOperation(SQLiteConnection conn)
        {
            var result = (SQLite3.Result)raw.sqlite3_prepare_v2(conn.Handle, "INSERT OR REPLACE INTO CacheElement VALUES (?,?,?,?,?)", out insertOp);
            Connection = conn;

            if (result != SQLite3.Result.OK) 
            {
                throw new SQLiteException(result, "Couldn't prepare statement");
            }

            inner = insertOp;
        }
开发者ID:jean-marc87,项目名称:Akavache,代码行数:12,代码来源:Operations.cs


示例18: BeginTransactionSqliteOperation

        public BeginTransactionSqliteOperation(SQLiteConnection conn)
        {
            var result = (SQLite3.Result)raw.sqlite3_prepare_v2(conn.Handle, "BEGIN TRANSACTION", out beginOp);
            Connection = conn;

            if (result != SQLite3.Result.OK)
            {
                throw new SQLiteException(result, "Couldn't prepare statement");
            }

            inner = beginOp;
        }
开发者ID:marciob,项目名称:Akavache,代码行数:12,代码来源:Operations.cs


示例19: Init

		public void Init()
		{
			using (var connection = new SQLiteConnection(DatabaseFilename))
			{
				EnableForeignKeys(connection);

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SAVED_STREAM_ITEM (ID TEXT PRIMARY KEY NOT NULL, 
																			TITLE TEXT, 
																			PUBLISHED TEXT, 
																			WEBURI TEXT, 
																			SHORT_CONTENT TEXT, 
																			CONTENT TEXT, 
																			IMAGE_FOLDER TEXT);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS TAG_ACTION (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
							ITEM_ID TEXT,
							TAG TEXT,
							ACTION_KIND INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_ITEM (ID TEXT PRIMARY KEY NOT NULL, 
										SORT_ID TEXT, TITLE TEXT, UNREAD_COUNT INTEGER, URL TEXT, HTML_URL TEXT, ICON_URL TEXT, FIRST_ITEM_MSEC INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_CAT (ID TEXT PRIMARY KEY NOT NULL, 
										SORT_ID TEXT, TITLE TEXT, UNREAD_COUNT INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS SUB_CAT_SUB_ITEM (CAT_ID TEXT, ITEM_ID TEXT);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS STREAM_COLLECTION (STREAM_ID TEXT PRIMARY KEY NOT NULL, CONTINUATION TEXT, SHOW_NEWEST_FIRST INTEGER, STREAM_TIMESTAMP INTEGER, FAULT INTEGER);"))
				{
					statement.Step();
				}

				using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS STREAM_ITEM (ID TEXT PRIMARY KEY NOT NULL, STREAM_ID TEXT REFERENCES STREAM_COLLECTION(STREAM_ID) ON DELETE CASCADE, PUBLISHED TEXT, TITLE TEXT, WEB_URI TEXT, CONTENT TEXT, UNREAD INTEGER, NEED_SET_READ_EXPLICITLY INTEGER, IS_SELECTED INTEGER, STARRED INTEGER, SAVED INTEGER);"))
				{
					statement.Step();
				}
			}
		}
开发者ID:valeronm,项目名称:handyNews,代码行数:53,代码来源:LocalStorageManager.cs


示例20: createTable

 public static void createTable()
 {
     using (var connection = new SQLiteConnection("Storage.db"))
     {
         using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS Student (
                                         ID NVARCHAR(10),
                                         NAME NVARCHAR(50),
                                         CGPA NVARCHAR(10));"))
         {
             statement.Step();
         }
     }
 }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:13,代码来源:DataBaseController.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SQLitePCL.sqlite3类代码示例发布时间:2022-05-26
下一篇:
C# Tests.TestDb类代码示例发布时间: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