Sql Server连接字符串

  写连接字符串时需要制定server(连接到哪一台电脑),database(连接到哪一个数据库)

一、使用SqlConnection对象时,需要指定连接字符串,下面是相关介绍:

uid(用户名),pwd(登陆密码),Integrated Security(连接协议true或SSPI),Initial Catalog

(连接到的数据库).下面是一些实例:

1

string connectionString = "server = 304b2;database = students; uid = sa; pwd = ";
    //304b2是本机名字,还可以是用local或 . 或 127.0.0.1

2

string connectionString = "server = .;database = students;Integrated Security = SSPI";

3

string connectionString = "server = .;Initial catalog= students;Integrated Security = SSPI";
posted @ 2012-06-09 16:26  金河  阅读(341)  评论(0编辑  收藏  举报