0

I am trying to learn mvc3/4 by trying to build my current project. How do you set the connection string for enterprise library? I have downloaded the libraries and added as reference. But I dont know how to set the connection string.

this is what I have now...

<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=UpdatedProducts;User ID=myUsername;Password=myPassword;AttachDBFilename=|DataDirectory|\aspnet-GuncelMalzemeler-20130430221215.mdf" />

do you guys have any idea how to set this connection?

4

1 回答 1

1

It's like this:

<configuration>
  <configSections>
    <section name="dataConfiguration" 
       type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
            Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, 
            Culture=neutral, PublicKeyToken=null" 
        requirePermission="false"/>
  </configSections>

  <dataConfiguration defaultDatabase="DefaultConnection" />

  <connectionStrings>
        <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=UpdatedProducts;User ID=myUsername;Password=myPassword;AttachDBFilename=|DataDirectory|\aspnet-GuncelMalzemeler-20130430221215.mdf" />
  </connectionStrings>
</configuration>

You may need to change the section type attribute based on the version of the enterprise library you are using.

于 2013-04-30T19:45:25.683 回答