Occassional "The underlying provider failed on Open. Connection must be opened." error

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
cbruen1
Posts: 9
Joined: Wed 23 Nov 2011 20:18

Occassional "The underlying provider failed on Open. Connection must be opened." error

Post by cbruen1 » Thu 18 Oct 2012 12:58

Hi - we're using dotConnect 6.60.283.0 with Entity Framework Code First and .NET MVC3. It works fine practically all the time except in one scenario, which is where we have a View that displays multiple images. Sometimes all images are loaded fine, other times some of the images fail to load and I get one of 2 error messages - "The connection was not closed" or "Connection must be opened".
I use an EditorTemplate to render the collection of images in the View, which makes a call to my Controller for each image. Here's the Razor code that calls the Controller method :

Code: Select all

<div>
    <img style="border: solid; border-color: lightgrey; border-width: thin" src="@Url.Action("GetImages", "Product", new {docId = Model.DocumentID, width = 250, height = 250})" alt=""/>            
</div>
And here's the Controller method:

Code: Select all

public void GetImages(int docId, int width, int height)
{
    // Load image from database
    var document = prodRepository.Documents.SingleOrDefault(f => f.DocumentID == docId);
    var image = document.FileContent;

    new WebImage(image)
	.Resize(width, height, true, true) 
	.Crop(1, 1)
	.Write();
}
My repository and context are set up in a standard way;

Code: Select all

public IQueryable<Document> Documents
{
    get { return prodContext.Documents; }
}

public IDbSet<Document> Documents { get; set; }
I think what's happening is that the Controller action is being called very fast several times in a row, especially when there are 4 or more images, and the db connection isn't fully closed before the next request comes in. So is there anything I can do? Is it possible to open and dispose the connection manually maybe, or some other pattern I can use to call a method multiple times in succession?

Cheers,

Ciaran

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Occassional "The underlying provider failed on Open. Connection must be opened." error

Post by Shalex » Tue 23 Oct 2012 12:26

Could you please create and send us a small test project with the corresponding DDL/DML script to reproduce the issue in our environment so that we can investigate it?

Post Reply