Connection string hell in .NET / LINQ-SQL / ASP.NET

后端 未结 13 1296
渐次进展
渐次进展 2021-01-30 14:29

I have a web application that comprises the following:

  • A web project (with a web.config file containing a connection string - but no data access code in the web pr
13条回答
  •  Happy的楠姐
    2021-01-30 14:43

    Thanks for the responses.

    Those of you who say the app will use the setting in the web.config are correct for instances where I reference it in my own code:

    _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
    

    ..but there is a different issue with LINQ-SQL datacontexts - I think they include connections strings in the compiled dll for use in the parameterless constructor. As tvanofosson says, I need to create datacontexts by passing in a reference to the connection string in the web.config. Which is where I was getting into a tangle :)

提交回复
热议问题