啊鑫
9 天以前 0aa54059b26e6641196e9953490dd18616e916e3
util/DbHelperSQL.cs
@@ -2,7 +2,7 @@
using System.Data;
using System.Data.SqlClient;
namespace Gs.Toolbox;
namespace NewPdaSqlServer.util;
/// <summary>
///     数据访问类
@@ -12,6 +12,18 @@
    //数据库连接字符串(web.config来配置)   
    public static readonly string strConn =
        getValueByKey("DataBaseConn");
    public static string getValueByKey(string key)
    {
        // 创建配置构建器
        var builder = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json", true, true);
        // 构建配置
        var configuration = builder.Build();
        return configuration[key];
    }
    #region 公用方法
@@ -571,6 +583,7 @@
            else
                str = str + "|" + command.Parameters[a].Value;
        }
        return str;
    }
@@ -672,17 +685,4 @@
    }
    #endregion
    public static string getValueByKey(string key)
    {
        // 创建配置构建器
        var builder = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("appsettings.json", true, true);
        // 构建配置
        var configuration = builder.Build();
        return configuration[key];
    }
}