安装完了数据库,在程序中使用就需要连接字符串。如何写呢?以sql server 2008 r2后为例。
1、安装好sql server 2008 r2后,类似oracle的plsql工具。sql server 2008 r2也有工具,那就是sql server management studio,如图

2、打开sql server management studio后,如图

服务器,用户名,密码都是在安装的时候自己输入的。
3、进入界面,可以创建自己的数据库名、也可以点击附件导入已有的数据库(mdf文件)。

或

4、例如,这里新建一个数据库名为:

连接字符串为:
Data Source=88226D6210524C7;Initial Catalog=HopeLoan2013;User ID=sa;pwd=yys
有值的地方改为自己的即可。
Sql Server数据库 002—sql server 2008 r2 连接字符串
原文:http://blog.csdn.net/yysyangyangyangshan/article/details/41925159