当前位置:编程学习 > C#/ASP.NET >>

asp.net web.config请问下面哪段代码是连接数据库的字符串

<?xml version="1.0" encoding="gb2312" ?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
 
  <configSections>
    <section name="CommerceDataProvider" type="Commerce.Providers.DataProviderConfigurationHandler, Commerce.DataProvider"/>
    <section name="CommerceOrdersProvider" type="Commerce.Providers.OrdersProviderConfigurationHandler, Commerce.OrdersProvider"/>
    <section name="CommerceShoppingCartProvider" type="Commerce.Providers.ShoppingCartConfigurationHandler, Commerce.ShoppingCartProvider"/>
    <section name="CommerceCatalogProvider" type="Commerce.Providers.CatalogProviderConfigurationHandler, Commerce.CatalogProvider"/>
    <section name="CommerceTaxProvider" type="Commerce.Providers.TaxProviderConfigurationHandler, Commerce.TaxProvider"/>
    <section name="CommerceShippingProvider" type="Commerce.Providers.ShippingProviderConfigurationHandler, Commerce.ShippingProvider"/>
    <section name="CommercePaymentProvider" type="Commerce.Providers.PaymentProviderConfigurationHandler, Commerce.PaymentProvider"/>
  </configSections>
  <appSettings>
    <!--PayPal Settings-->
    <add key="SimpleTaxRate" value="0.0825"/>
    <add key="BusinessEmail" value="business@csk.com"/>
    <add key="RequireShipping" value="True"/>
    <add key="RequireLogin" value="checkout"/>
    <add key="SecureURL" value="http://localhost/pp2/"/>
    <add key="SiteURL" value="http://localhost/pp2/"/>
    <add key="ShipFromZip" value="96960"/>
    <add key="ShowZeroInventoryItems" value="True"/>

    <!--the sandbox is PayPal's development server-->
    <add key="UseSandbox" value="True"/>
    <add key="UseDirectPay" value="True"/>

    <!--setting this to true will override DirectPay-->
    <add key="UsePayPalPaymentsStandard" value="False"/>
   
    <!--this is the currency code that will be sent to process the transaction
    valid codes are "USD" (us dollar), "EUR" (euro), "GBP" (Brit pound), JPY (Japanese yen) etc.
    -->
    <add key="CurrencyCode" value="USD"/>
   
    <!--PayPal Payments Pro Settings     -->
    <!--make sure you also set the PaymentProvider settings below
    The below if for the ExpressCheckout
    -->
    <add key="PayPalAPIAccountName" value="business_api1.csk.com"/>
    <add key="PayPalAPIAccountPassword" value="commerce"/>
    <add key="PayPalAPICertificate" value="csk.pfx"/>
    <add key="PayPalAPICertificationPassword" value="commerce"/>

    <!--PayPal Payments Standard Settings-->
    <add key="PayPalPDTID" value="4wscjERBD3ik_E7hmrqVaXHilJTCegrJ5FJogluERPo8H9ixPskOmFXuQK8"/>
  </appSettings>

  <!--this is for the DirectPay-->
  <CommercePaymentProvider defaultProvider="PayPalPaymentProvider">
    <providers>
      <clear/>
      <add name="PayPalPaymentProvider"
      type="Commerce.Providers.PayPalPaymentProvider, Commerce.PaymentProvider"
      serviceUserName="business_api1.csk.com"
      servicePassword="commerce"
      sslCertFile="csk.pfx"
      sslCertPassword="commerce"
      merchantID="csk@wekeroad.com"
      />
 
    </providers>
  </CommercePaymentProvider>
  <CommerceShippingProvider defaultProvider="SqlShippingProvider">
    <providers>
      <clear/>
      <add name="SqlShippingProvider"
    type="Commerce.Providers.SqlShippingProvider, Commerce.ShippingProvider"
    connectionStringName="CommerceTemplate"/>
    </providers>
  </CommerceShippingProvider>
  <CommerceTaxProvider defaultProvider="SqlTaxProvider">
    <providers>
      <clear/>
      <add name="SqlTaxProvider"
        type="Commerce.Providers.SqlTaxProvider, Commerce.TaxProvider"
        connectionStringName="CommerceTemplate"/>
    </providers>
  </CommerceTaxProvider>
  <CommerceOrdersProvider defaultProvider="SqlOrdersProvider">
    <providers>
      <clear/>
      <add name="SqlOrdersProvider"
        type="Commerce.Providers.SqlOrdersProvider, Commerce.OrdersProvider"
        connectionStringName="CommerceTemplate"/>
   </providers>
  </CommerceOrdersProvider>
 <CommerceShoppingCartProvider defaultProvider="SqlShoppingCartProvider">
   <providers>
    <clear/>
    <add name="SqlShoppingCartProvider"
     type="Commerce.Providers.SqlShoppingCartProvider, Commerce.ShoppingCartProvider"
     connectionStringName="CommerceTemplate"/>
   </providers>
  </CommerceShoppingCartProvider>
 <CommerceCatalogProvider defaultProvider="SqlCatalogProvider">
  <providers>
   <clear/>
   <add name="SqlCatalogProvider"
    type="Commerce.Providers.SqlCatalogProvider, Commerce.CatalogProvider"
    connectionStringName="CommerceTemplate"/>
  </providers>
 </CommerceCatalogProvider>


 <connectionStrings>
  <clear/>
  
  <add name="CommerceTemplate"
   connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|CommerceDB.mdf" providerName="System.Data.SqlClient" />
  <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNET.mdf" providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
  <!--
    <globalization
    requestEncoding="utf-8"
    responseEncoding="utf-8"
    fileEncoding="utf-8"
    culture="en-US"
    uiCulture="en" />
  <trust level="Medium" originUrl="http://localhost/pp2"  />
  -->
  <roleManager enabled="true"/>
  <membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="15" hashAlgorithmType=""
     >
   <providers>
    <clear/>
    <add connectionStringName="LocalSqlServer"
     enablePasswordRetrieval="false"
     enablePasswordReset="true"
     requiresQuestionAndAnswer="true"
     applicationName="/"
     requiresUniqueEmail="false"
     passwordFormat="Hashed"
     maxInvalidPasswordAttempts="5"
     passwordAttemptWindow="10"
     passwordStrengthRegularExpression=""
     minRequiredPasswordLength="1"
     minRequiredNonalphanumericCharacters="0"
     name="AspNetSqlMembershipProvider"
     type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
   </providers>
  </membership>
  <anonymousIdentification enabled="true"/>
  <authentication mode="Forms">
   <forms name=".ASPNET" loginUrl="login.aspx" protection="All" timeout="30" path="/"/>
  </authentication>
  <authorization>
   <allow users="?" />
  </authorization>
  <profile automaticSaveEnabled="true">
   <!--
   <providers>
    <clear/>
    <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="CommerceTemplateSQL"/>
   </providers>
   -->
   <properties >
    <group name="Commerce">
     <!--shipping prefs-->
     <add name="ShipFirst" type="System.String" allowAnonymous="true"/>
     <add name="ShipLast" type="System.String" allowAnonymous="true"/>
     <add name="ShipCity" type="System.String" allowAnonymous="true"/>
     <add name="ShipAddress1" type="System.String" allowAnonymous="true"/>
     <add name="ShipAddress2" type="System.String" allowAnonymous="true"/>
     <add name="ShipState" type="System.String" allowAnonymous="true"/>
     <add name="ShipZip" type="System.String" allowAnonymous="true"/>
     <add name="ShipCountry" type="System.String" allowAnonymous="true"/>
     <add name="ShipPhone" type="System.String" allowAnonymous="true"/>

     <!--encrypted info-->
     <add name="CCNumber" type="System.String" allowAnonymous="true"/>
     <add name="CCType" type="System.String" allowAnonymous="true"/>
     <add name="CCExpMonth" type="System.String" allowAnonymous="true"/>
     <add name="CCExpYear" type="System.String" allowAnonymous="true"/>
     <add name="CCAuthNumber" type="System.String" allowAnonymous="true"/>

    </group>
    <add name="First" type="System.String" allowAnonymous="true"/>
    <add name="Last" type="System.String" allowAnonymous="true"/>
    <add name="City" type="System.String" allowAnonymous="true"/>
    <add name="Address1" type="System.String" allowAnonymous="true"/>
    <add name="Address2" type="System.String" allowAnonymous="true"/>
    <add name="State" type="System.String" allowAnonymous="true"/>
    <add name="Zip" type="System.String" allowAnonymous="true"/>
    <add name="Country" type="System.String" allowAnonymous="true"/>
    <add name="Phone" type="System.String" allowAnonymous="true"/>
    

   </properties>
  </profile>
  <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
  <compilation debug="true">
   <assemblies>
    <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
  <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
  <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
        -->

        <customErrors mode="Off">
        </customErrors>
    <pages styleSheetTheme="White" />
 </system.web>
 <system.net>
  <mailSettings>
   <smtp from="me@email.com">
    <network host="my.email.com" password="password" userName="username" />
   </smtp>
  </mailSettings>
 </system.net>

</configuration>

追问:为什么没有密码字符。如果有密码请问怎么改?

答案: <add name="CommerceTemplate"
   connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|CommerceDB.mdf" providerName="System.Data.SqlClient" />
  <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNET.mdf" providerName="System.Data.SqlClient" />

<add name="CommerceTemplate"
   connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|CommerceDB.mdf" providerName="System.Data.SqlClient" />
  <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNET.mdf" providerName="System.Data.SqlClient" />

这段

<connectionStrings>
  <clear/>
  
  <add name="CommerceTemplate"
   connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|CommerceDB.mdf" providerName="System.Data.SqlClient" />
  <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNET.mdf" providerName="System.Data.SqlClient" />
 </connectionStrings>
你这个应该是安装VS目录下的machine.config文件吧

上一个:利用ASP实现数据库的模糊查询,请指出哪些是主要代码并解释含义
下一个:asp里面写在客户端和写在浏览器端的代码有什么不同

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,