web.config重写machine.config中的LocalSqlServer

在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错
可以试试下面的方法,我们这样设置的话也对成立自己的数据有更好的解决方案
文章来自本人163博客:http://blog.163.com/it_huo/blog/

<? xml version="1.0" ?>
< configuration  xmlns ="http://schemas.microsoft.com/.NetConfiguration/v2.0" >
 
< appSettings />
 
< connectionStrings >   
  
< add  name ="aspnetdb"  connectionString ="Data Source=.;Initial Catalog=webPart;Persist Security Info=True;User ID=sa;Password=wskfire"  providerName ="System.Data.SqlClinet" />
 
</ connectionStrings >
 
< system .web >
  
< compilation  debug ="true" />
  
< authentication  mode ="Forms"   />
  
< webParts  enableExport ="true" >
   
< personalization  defaultProvider ="AspNetSqlProvider" >
    
< providers >
     
< add  name ="AspNetSqlProvider"  type =" System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"  connectionStringName ="aspnetdb"  applicationName ="/" />
    
</ providers >
    
< authorization >
     
< allow  roles ="admin"  verbs ="enterSharedScope" />
     
< allow  users ="*"  verbs ="modifyState" />
    
</ authorization >
   
</ personalization >
  
</ webParts >
  
< membership  defaultProvider ="AspNetSqlProvider" >
   
< providers >
    
< add  type ="System.Web.Security.SqlMembershipProvider"  name ="AspNetSqlProvider"  connectionStringName ="aspnetdb"  applicationName ="/"  description =""  minRequiredPasswordLength ="6"  minRequiredNonalphanumericCharacters ="0"  requiresUniqueEmail ="false"  enablePasswordRetrieval ="false"  enablePasswordReset ="false"  passwordFormat ="Hashed"  requiresQuestionAndAnswer ="true" />     
   
</ providers >
  
</ membership >
  
< roleManager  enabled ="true"  defaultProvider ="AspNetSqlProvider" >
   
< providers >
    
< add  type ="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  connectionStringName ="aspnetdb"  name ="AspNetSqlProvider"  applicationName ="/"  description ="" />     
   
</ providers >
  
</ roleManager >
 
</ system.web >
</ configuration >

你可能感兴趣的:(sqlserver)