Data Server=.\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa;Password=sapassSql Data Server=服务器名\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa;Password= sapassSql Data Server=localhost\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa;Password= sapassSql Data Server=.;Initial Catalog=Northwind;User ID=sa;Password= sapassSql Data Server=服务器名;Initial Catalog=Northwind;User ID=sa;Password= sapassSqlVisual Studio 2005和SQL Server 2005创建数据库连接
中文分号改掉
Data Server=服务器名\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa;Password= sapassSql
Data Server=localhost\SQLEXPRESS;Initial Catalog=Northwind;User ID=sa;Password= sapassSql
Data Server=.;Initial Catalog=Northwind;User ID=sa;Password= sapassSql
Data Server=服务器名;Initial Catalog=Northwind;User ID=sa;Password= sapassSqlVisual Studio 2005和SQL Server 2005创建数据库连接
不行你就在视图的“服务器资源管理器”来添加SQL Server 2005的连接,通过输入服务器名称和对应的SQL Server身份验证的sa用户名密码后,选取对应的数据库,然后点击“测试连接”,就会成功的连接到数据库了。(如果这都有问题,那就是你配置问题了.)
可以的话,把属性里的连接字符串复制出来用吧.
sqlconnection con=new sqlconnection(strcon)
con.open();
SQL Server 2005和SQL Server 2000 用法有区别,参见5楼的链接.