记一次纯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强多了

转载于:https://www.cnblogs.com/virtualWindGuest/p/11589845.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值