How to write connection string in web.config file and read from it?

后端 未结 7 1283
日久生厌
日久生厌 2020-12-16 00:57

I\'m trying to write Connection string to Web.config like this:


  

        
相关标签:
7条回答
  • 2020-12-16 01:20

    Are you sure that your configuration file (web.config) is at the right place and the connection string is really in the (generated) file? If you publish your file, the content of web.release.config might be copied.

    The configuration and the access to the Connection string looks all right to me. I would always add a providername

    <connectionStrings>
      <add name="Dbconnection" 
           connectionString="Server=localhost; Database=OnlineShopping; 
           Integrated Security=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
    
    0 讨论(0)
提交回复
热议问题