App.config中的连接字符串 [英] Connection String in App.config

查看:89
本文介绍了App.config中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我是WPF的新手.我想在App.config文件中维护我的connectionString.
我该如何保养?我正在使用VS2010 WPF,SQLServer2005.

解决方案

可以.即使您不熟悉WPF,在将ConnectionString保留在Config文件中的情况下,它与普通的Winforms编程或Web编程也没有太大区别.

此外,一旦在配置文件中定义了连接字符串,它就不会自动更改.只要您自己不手动或通过代码对其进行更改,它将保持不变.

只需将连接字符串放入配置文件中,就像将其他值放入配置文件中,并在需要时访问它即可. .net应用程序


如果您的数据库仍附加到sql服务器,则使用以下连接字符串

<添加name ="cs" connectionString ="server = .; database =" mydatabase"uid = sa"/>

希望它能工作. :)


Hi to all,
I am new to WPF. I want to maintain my connectionString in App.config file.
How can I maintain it? I am using VS2010 WPF, SQLServer 2005.

解决方案

It''s ok. Even if you are new to WPF, it''s not much different from normal Winforms programming or Web programming in case of keeping ConnectionString in Config file.

Further, once the connection string is defined in the config file, it would not get automatically changed. It will remain the same as long as you yourself don''t change it manually or by code.

Just put the Connection String in your config file as you put other values in it and access it when needed.


i guess ,the connection string remains the same weather u are working on wpf or simple .net application


if your database is still attatched to the sql server then use the following connection string

<add name="cs" connectionString="server=.;database="mydatabase" uid=sa"/>

hope it works. :)


这篇关于App.config中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆