以前写Asp.net代码,用的Web.Config配置文件中连接字符串多是

         <appSettings>
           <add key="ConnectionString"  value="Server=.;Integrated Security=SSPI;Database=Message;" />
         </appSettings> 

        在Asp.Net 2.0  中新加了<connectionStrings>这一节

       <connectionStrings > 
          <add />
          <clear />
          <remove />
       </connectionStrings>

        现在用起来就方便些了

       <connectionStrings>

         <add name="Sales"
              providerName="System.Data.SqlClient"
              connectionString= "server=myserver;database=Products;uid=salesUser;pwd=sellMoreProducts" />

       </connectionStrings>

         使用时,只需要如下即可:

        System.Configuration.ConfigurationManager.ConnectionStrings["Sales"]

相关文章:

  • 2021-09-24
  • 2021-12-05
  • 2022-12-23
  • 2022-02-25
  • 2021-12-18
  • 2022-12-23
  • 2021-06-09
  • 2021-08-23
猜你喜欢
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-07-19
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案