2012-04-15 48 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