C# vs2005 做一个界面,显示一个表信息,并对其进行增删改查操作。我是通过“数据”,“添加数据源”,“使用设计器编辑数据集”。
然后直接把字段和表拉到Form中,自动绑定,完成设计界面。VS自动生成app.config,但是 XXXConnectionString 是连接字符串
public string XXXConnectionString {
get {
return ((string)(this["XXXConnectionString "]));
}
只读的,没有Set,我不能通过其他地方动态设置config连接语句了。我该怎么办,才能对app.config进行设置,以及加密?
然后直接把字段和表拉到Form中,自动绑定,完成设计界面。VS自动生成app.config,但是 XXXConnectionString 是连接字符串
public string XXXConnectionString {
get {
return ((string)(this["XXXConnectionString "]));
}
只读的,没有Set,我不能通过其他地方动态设置config连接语句了。我该怎么办,才能对app.config进行设置,以及加密?
解决方案 »
- 未将对象引用到对象实例
- DX控件中Gridview点击NEW EDIT DELETE按钮 一直处于loading状态?
- 怎么统计一个表中指定的字段中有几个相同的记录?
- 一个局域网访问数据库的问题
- 正则表达式替换
- 多线程函数参数问题
- 在一个类中,有这样一个函数,它错在哪里?
- 用Windows的权限来做asp.net Web应用程序的权限管理!
- App.config中 除了connectionStrings和appSettings字节,其它字节的数据怎么读取,更新,删除
- 请问c#如果调用Shell32.dll实现打印功能
- 控件绑定数据,如果是DataTable怎样才能让其针对的是属性而不是数据?
- 手风琴式导航菜单的权限控制问题
private void SetValue(String AppKey, String AppValue)
{
XmlDocument xDoc=new XmlDocument();
xDoc.Load(GetAppName("file"));//配置文件名需修改
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode=xDoc.SelectSingleNode("//connectionStrings");
xElem1=(XmlElement)xNode.SelectSingleNode("//add[@name=\""+AppKey+"\"]");
if(xElem1!=null)
xElem1.SetAttribute("connectionString",AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("name",AppKey);
xElem2.SetAttribute("connectionStrings",AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(GetAppName("file"));//配置文件名需修改
}