• 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);
  • 相关阅读:
    5个排序算法
    原生侧边栏sidebar
    静态方法、实例方法、继承
    函数作用域之闭包与this!
    OOP面向对象编程(下)
    数组方法篇二
    对象
    nginx windows负载均衡入门
    NVelocity
    python3简单爬虫
  • 原文地址:https://www.cnblogs.com/GarsonZhang/p/14047117.html
Copyright © 2020-2023  润新知