2010年11月5日 星期五

web.config中連結SQL資料庫的驗證方式

使用.NET開發工具時當要與資料庫做溝通時一定會用的連線驗證方式,本次以連結SQL資料庫連線為例,主要可區分SQL Server與Windows驗證兩種方式。


SQL Server驗證方式:
 <configuration>
<connectionStrings>
  <add name="NorthWindConnectionString"
                         connectionString="Data Source=.;
                          Initial Catalog=NorthWind;
                         User ID=sa;Password=123"
                         providerName="System.Data.SqlClient"/>
</connectionStrings>
Windows驗證方式:
 <configuration>
<connectionStrings>
  <add name="NorthWindConnectionString" 
                         connectionString="Data Source=.;
                          Initial Catalog=NorthWind;
                         Integrated Security=True"
                         providerName="System.Data.SqlClient"/>
</connectionStrings>

沒有留言:

張貼留言