Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting an error on website when multiple users access same page simultaneoulsy
    primarykey
    data
    text
    <p>I'm getting the following error message on an ASP.NET 4 website when multiple users access the same page:</p> <blockquote> <p>The underlying provider failed to open. at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf etc......</p> </blockquote> <p>I use Entity Framework 4 to access the SQL Server 2008 database.</p> <p>The page works sometimes so I know the connection string is correct. Also the Database is set to multi user and I have MARS set to true in connection string.</p> <p>Also in the event viewer I sometimes get the SQL Server message :</p> <blockquote> <p>The server will drop the connection, because the client driver has sent multiple requests while the session is in single-user mode.</p> </blockquote> <p>As I say, this only happens if I try accessing the same page simultaneously on two different machines by just refreshing the page or clicking the same link.</p> <p>Any help would be much appreciated.</p> <p>Connection strings added (first one for ASPNETDB and second for main database):</p> <pre><code>&lt;add name="ApplicationServices" connectionString="Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=False;Persist Security Info=False;User ID=****;Password=****;Connect Timeout=120" /&gt; &lt;add name="MyDBEntities" connectionString="metadata=res://*/App_Code.MyDBModel.csdl|res://*/App_Code.MyDBModel.ssdl|res://*/App_Code.MyDBModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=False;User ID=****;Password=****;Connect Timeout=120;User Instance=false;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient" /&gt; </code></pre> <p>The Class I use to access the context is as follows:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using MyDBModel; using System.Web.Security; /// &lt;summary&gt; /// Summary description for MyDataAccess /// &lt;/summary&gt; public static class MyDataAccess { // Private Class Members //----------------------------------------------------------------------------------------- private static MyDBModel.MyDBEntities dal = new MyDBModel.MyDBEntities(); // Class Constructor / Destructor //----------------------------------------------------------------------------------------- static MyDataAccess() { // Set Entity ObjectContext Merge Options - this basically ensures database items aren't cached dal.NEWS.MergeOption = System.Data.Objects.MergeOption.OverwriteChanges; dal.NEWS_IMAGES.MergeOption = System.Data.Objects.MergeOption.OverwriteChanges; } // Public Methods for Data Access //----------------------------------------------------------------------------------------- /// &lt;summary&gt; /// Get All Current News Items /// &lt;/summary&gt; public static List&lt;NEWS&gt; GetCurrentNewsItems() { var items = from news in dal.NEWS where news.NEWS_ACTIVE == true &amp;&amp; news.NEWS_STARTDATE &lt;= DateTime.Today &amp;&amp; news.NEWS_EXPIRYDATE &gt;= DateTime.Today orderby news.NEWS_DATE descending select news; return NewsManager.GetMyNewsItems(items).ToList(); } } </code></pre> <p>Then within my .aspx.cs page I would use something like:</p> <pre><code>var news = MyDataAccess.GetCurrentNewsItems(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload