当前位置: 首页>>代码示例>>C#>>正文


C# SQLitePCL.SQLiteConnection类代码示例

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


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


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