sql2005企業(yè)版連接到數(shù)據(jù)庫(kù)(象access一樣)
廣告:
應(yīng)把.\sqlexpress 改為 .\sql2005 (示例) 并且把 User Instance=true 改為 User Instance=false
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data
source=.\SQL2005;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf
;User Instance=true"
providerName="System.Data.SqlClient"/>
<add name="classifiedsConnection"
connectionString="Data Source=SCEFHAO\SQL2005;Initial
Catalog=CLASSIFIEDSDB;User ID=sa;Password=hao123;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
出現(xiàn)"此版本的sql server不支持用戶實(shí)例登陸標(biāo)志"錯(cuò)誤。應(yīng)改為
User Instance=false;
以下為正確連接:
<connectionStrings>
<add name="classifiedsConnection"
connectionString="Data
Source=.\SQL2005;AttachDbFilename=|DataDirectory|classifie
dsdb.mdf;Integrated Security=True;User Instance=false"
providerName="System.Data.SqlClient"/>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data
source=.\SQL2005;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf
;User Instance=false"
providerName="System.Data.SqlClient"/>
<!-- <add name="classifiedsConnection"
connectionString="Data Source=SCEFHAO\SQL2005;Initial
Catalog=CLASSIFIEDSDB;User ID=sa;Password=hao123;"
providerName="System.Data.SqlClient"/>-->
</connectionStrings>
這樣就可以象操作access數(shù)據(jù)庫(kù)一樣操作sql2005的數(shù)據(jù)庫(kù)了,不過(guò)這樣程序運(yùn)行時(shí)會(huì)自動(dòng)在sql2005企業(yè)管理器自動(dòng)生成以路徑命名的數(shù)據(jù)庫(kù)名(iis中無(wú)效,僅針對(duì)vs2008環(huán)境中).
廣告: