2012-04-15 33 views
0

我正在一个Web应用程序中,我必须添加一些授权,所以我有一个数据库ASPNETDB.MDF,我希望我的应用程序从SQL Server使用WATERINFO.MDF。更新web.config以将aspnetdb更改为自己的数据库?

我已经upadted WATERINFO.MDF使用aspnet_regsql.exe的

目前Silverlight应用程序的我的web.config文件中的所有架构和数据是

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="system.serviceModel"> 
     <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 

    <system.web> 
    <httpModules> 
     <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpModules> 
    <compilation debug="true" targetFramework="4.0" /> 

    <roleManager enabled="true"/> 

    <authentication mode="Forms"> 
     <forms name=".AuthorizationSample_ASPXAUTH" /> 
    </authentication> 

    <profile> 
     <properties> 
     <add name="FriendlyName"/> 
     </properties> 
    </profile> 

    </system.web> 

    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="DomainServiceModule" preCondition="managedHandler" 
      type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </modules> 
    </system.webServer> 

    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
</configuration> 

现在把它改为WATERINFO.MDF我需要更新配置文件

 <?xml version="1.0"?> 
    <configuration> 
<connectionStrings> 
     <add name="DefaultConnectionString" connectionString="Data Source=COMPLEX\SQLEXPRESS;Initial Catalog=waterinfo;Integrated Security=True" 
    providerName="System.Data.SqlClient" /> 

     </connectionStrings> 
     <configSections> 
     <sectionGroup name="system.serviceModel"> 
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" /> 
     </sectionGroup> 
     </configSections> 



     <system.web> 

     <roleManager enabled="true" defaultProvider="DPISqlRoleProvider"> 
      <providers> 
      <add connectionStringName="DefaultConnectionString" applicationName="DPI" name="DPISqlRoleProvider" 
    type="System.Web.Security.SqlRoleProvider"/> 

      </providers> 
     </roleManager> 
     <httpModules> 
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </httpModules> 
     <compilation debug="true" targetFramework="4.0" /> 



     <authentication mode="Forms"> 

     </authentication> 


     <membership defaultProvider="DPISqlMembershipProvider"> 

      <providers> 
      <add connectionStringName="DefaultConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" 
    requiresQuestionAndAnswer="true" applicationName="DPI" requiresUniqueEmail="true" passwordFormat="Hashed" 
    maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" 
    passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="DPISqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/> 

      </providers> 
     </membership> 
     <profile> 
      <properties> 
      <add name="FriendlyName"/> 
      </properties> 
     </profile> 

     </system.web> 

     <system.webServer> 
     <validation validateIntegratedModeConfiguration="false"/> 
     <modules runAllManagedModulesForAllRequests="true"> 
      <add name="DomainServiceModule" preCondition="managedHandler" 
       type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     </modules> 
     </system.webServer> 

     <system.serviceModel> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
     </system.serviceModel> 
    </configuration> 

我更新我的web.config文件中的这些变化,但无法将数据库更改为新的。

而且我知道我可以使用<remove "LocalSqlServer">但现在好生产用

请建议我应该在我的web.config文件中什么样的变化。

感谢

回复

+0

更改标题和内容,如你想改变承载Silverlight包的此Web站点的设置。它仍然是一个网站,改变它的设置与Silverlight无关。 – 2012-04-15 08:45:09

回答

0

我解决了问题,也有一些连接字符串错误和其他一些时刻变化......我需要更新Web.Config文件这样

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <sectionGroup name="system.serviceModel"> 
     <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" /> 
    </sectionGroup> 
    </configSections> 
    <connectionStrings> 
    <add name="DefaultConnectionString" connectionString="My Connection Details" 
providerName="System.Data.SqlClient" /> 

    </connectionStrings> 


    <system.web> 

    <roleManager enabled="true" defaultProvider="DPISqlRoleProvider"> 
     <providers> 
     <add connectionStringName="DefaultConnectionString" applicationName="DPI" name="DPISqlRoleProvider" 
type="System.Web.Security.SqlRoleProvider"/> 

     </providers> 
    </roleManager> 
    <httpModules> 
     <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </httpModules> 
    <compilation debug="true" targetFramework="4.0" /> 



    <authentication mode="Forms"> 

    </authentication> 


    <membership defaultProvider="DPISqlMembershipProvider"> 

     <providers> 
     <add connectionStringName="DefaultConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" 
requiresQuestionAndAnswer="true" applicationName="DPI" requiresUniqueEmail="true" passwordFormat="Hashed" 
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" 
passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="DPISqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/> 

     </providers> 
    </membership> 
    <profile> 
     <properties> 
     <add name="FriendlyName"/> 
     </properties> 
    </profile> 

    </system.web> 

    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="DomainServiceModule" preCondition="managedHandler" 
      type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
    </modules> 
    </system.webServer> 

    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
</configuration> 
0

你需要把下面的configSections的标签的ConnectionStrings。 configSections必须是第一个,如msdn中所述。

+0

你确实改变了它并更新了问题。但它没有连接 – TheBond 2012-04-15 08:55:08

相关问题