zoukankan      html  css  js  c++  java
  • GZDBHelper SQLite

    NUGET引用

    System.Data.SQLite.Core
    System.Data.SQLite.Linq

    安装System.Data.SQLite.Linq后,会生成一个app.config文件,

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      
    <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SQLite" />
          <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
        </DbProviderFactories>
      </system.data></configuration>

    安装GZDBHelper:

        public class GZDbParameterSQLite : GZDbParameter
        {
            public void AddParameter(string parameterName, System.Data.DbType dbType, object value)
            {
                SQLiteParameter p = new SQLiteParameter(parameterName, dbType);
                p.Value = value;
                this.AddParameter(p);
            }
        }
     StringBuilder sql = new StringBuilder();
                    sql.AppendLine("INSERT INTO tb_files(type,fileName)");
                    sql.AppendLine("VALUES(@type,@fileName)");
    
                    GZDbParameterSQLite parms = new GZDbParameterSQLite();
                    parms.AddParameter(new SQLiteParameter("@type", System.Data.DbType.String, type));
                    parms.AddParameter(new SQLiteParameter("@fileName", System.Data.DbType.String, fileName));
    
    
                    DBSQLite.Context.ExecuteNonQuery(sql.ToString(), parms);
  • 相关阅读:
    java security
    java 反射 动态代理
    java 泛型
    angularjs编码实践
    angularjs 资源集合
    java 类的加载,链接,初始化
    java 伪共享
    java cpu缓存
    SpringMVC,Controller的返回页面类型以及路径设置默认值
    org.springframework.web.bind.annotation重定向的问题
  • 原文地址:https://www.cnblogs.com/GarsonZhang/p/14047117.html
Copyright © 2011-2022 走看看