gpt4 book ai didi

web-config - 从 web.config 检索 IBATIS.NET 连接字符串的最佳方法

转载 作者:行者123 更新时间:2023-12-01 13:09:18 26 4
gpt4 key购买 nike

我有一个网络应用程序,我需要在 web.config 中加密和存储连接字符串。

检索此连接字符串并将此连接字符串与 IBATIS.NET 一起使用而不是将连接字符串存储在 SqlMap.config 中的最佳方法是什么?

最佳答案

this discussion thread的最后三条消息讨论你想要什么。

本质上,您是在调用 Configure() 之前覆盖 iBATIS 从配置文件加载的连接字符串。

例如,在您的 SqlMap.config 中:


<database>
<provider name="sqlServer2005" />
<dataSource name="TheDB" connectionString="${connectionString}"/>
</database>

在您配置构建器的代码中,类似于:


DomSqlMapBuilder builder;
string connection;
NameValueCollection properties;

connection = AccessTheEncryptedStringHere();

// Put the string in collection to pass to the iBATIS configurator
properties = new NameValueCollection();
properties.Add("connectionString", connection);

// Build the iBATIS configurator
builder = new DomSqlMapBuilder();
builder.Properties = properties;
builder.Configure("SqlMap.config");

关于web-config - 从 web.config 检索 IBATIS.NET 连接字符串的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/390595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com