zoukankan      html  css  js  c++  java
  • 记一次纯sqlite数据库的小项目开发经历

    sqlite有哪些坑

    1.支持的数据量级:根据SQLite的官方提示:http://www.sqlite.org/limits.html
    SQLIte数据库最大支持128TiB(140 terabytes, or 128 tebibytes, or 140,000 gigabytes or 128,000 gibibytes).

    2.sqlite支持T-Sql,不得不说 T-Sql是个很强大的东西,到哪都能用

    3.如何访问sqlite

       引入System.Data.SQLite.dll

    使用 DbProviderFactories实例化

     webconfig配置:

    <connectionStrings>

         <add name="sqlite" connectionString="Data Source=|DataDirectory|inventoryDb.db;Pooling=true;FailIfMissing=false" providerName="System.Data.SQLite" />

    </connectionStrings>

    <system.data>

        <DbProviderFactories>

             <add name="SQLiteFactory" invariant="SQLiteFactory" description="xxxxxxx" type="System.Data.SQLite.SQLiteFactory,System.Data.SQLite" />

        </DbProviderFactories>

    </system.data> 

     private static object _locker = new object();//锁对象
    
        private static DbProviderFactory _factory;//抽象数据工厂
    
        private static string _connectionstring;//关系数据库连接字符串
    
    
        /// <summary>
        /// 关系数据库连接字符串
        /// </summary>
        public static string ConnectionString
        {
            get { return _connectionstring; }
        }
    
    
        static DBHelperSqlite()
        {
            _factory = DbProviderFactories.GetFactory("SQLiteFactory");
    
            string dbName = ConfigurationManager.AppSettings["sqliteDbName"];
            _connectionstring = string.Format(ConfigurationManager.ConnectionStrings["sqlite"].ToString(),dbName);
        }

    4.t-sql语法问题

       topN :select {1} from {4} where {2} Order By {3} limit {0}

       分页: select {0} from {5} where {2} order by {1} limit {4} offset {3}

    使用起来很方便,比Access强多了

  • 相关阅读:
    最近比较毁硬件
    如何编写 Visual C++ 的表达式分析插件
    Windows 安全性编程
    MMX写的memcpy测试
    今天终于摆平了DeskBand
    ASP.NET后台代码调用前台javascript脚本的方法
    ArcGIS Server 9.3前后台交互调用实现点定位
    Oracle中建立存储过程
    建表时自动增加oracle表中记录的ID值
    特定图层的渲染
  • 原文地址:https://www.cnblogs.com/shellphen/p/11589845.html
Copyright © 2011-2022 走看看