tags:

views:

54

answers:

3

I am getting the above error when i retreived the data from the Datacontext Model.

it is happening now and then also.

A: 

You have forget to close the DataReader, and you start one more DataReader on the same connection.

Aristos
+1  A: 

Ensure that you're not declaring your DataContext as static. Create and destroy your DataContext on each use.

public MyDataClass{

    CustomerDataContext db;

    public void MyDataClass()
    {
       db = new CustomerDataContext();
    }

    public Customer GetCustomer(int id)
    {
       return db.Customers.SingleOrDefault(c=>c.ID == id);
    }
} 
p.campbell
A: 

Check this post

http://stackoverflow.com/questions/1094443/is-mixing-ado-net-and-linq-to-sql-bad-my-data-layer-isnt-working

It realy depends how you store, access and dispose the datacontext. Try to reproduce the error using a load test tool. I use jmeter. Lots of people don't know that they have this issue, because they have too little traffic.

Malcolm Frexner