日期:2014-05-20  浏览次数:21004 次

vs2010连接sqlserver的windows身份,怎么连接?
帮帮忙!谢谢了!

------解决方案--------------------
连接字符串, Integrated Security=SSPI
------解决方案--------------------
XML code

<configuration>
 <connectionStrings>
  <!-- Windows 身份验证 -->
        <!--<add name="ConnectionString" connectionString="Data Source=.;Initial Catalog=TestDB;Integrated Security=True" providerName="System.Data.SqlClient" />-->
  <!-- SQL Server 身份验证 -->
        <add name="ConnectionString" connectionString="Data Source=.;Initial Catalog=TestDB;Persist Security Info=True;User ID=sa;Password=sa" providerName="System.Data.SqlClient" />
 </connectionStrings>
</configuration>

------解决方案--------------------
1,Windows验证

Common.ConnString = @"Initial Catalog=数据库名;Data Source=电脑名或IP地址;Integrated Security=SSPI";

2, Sql混合验证

Common.ConnString = @"server=电脑名或IP地址;database=数据库名;uid=用户名;password=密码";