title: Django SQL Server Error: "Cannot create new connection because in manual or distributed transaction mode."
body: <p>I have some strange issue with querying SQL Server from django.</p>
  
  <p>When I query db twice in single request, I got errors in some cases. Namely when first db query returns big amount of data, we end up with error while querying db second time.</p>
  
  <p><strong>Details:</strong></p>
  
  <p>We're using Microsoft SQL Server backend for Django (https://bitbucket.org/Manfre/django-mssql/src) running on windows. </p>
  
  <p>We want allow user to filter data from some table ("Activity") via form, display it on the website's table and then show related data from another table ("Frames") on map. </p>
  
  <pre><code>class Frames(models.Model):
  ...
  
  class Activity(models.Model):
  frame_from = models.ForeignKey(Frames, ...)
  ...
  </code></pre>
  
  <p>The problem is: when we want to filter larger amount of data from Activity (let's say 200rows x 6 colums), we can not make other queries in the same request on table Frames (MARS is turned on in Django settings.py): </p>
  
  <pre><code>result = Aktywnosci.objects.filter(qset1) 
  </code></pre>
  
  <p>is always ok, but </p>
  
  <pre><code>path = Frames.objects.filter(qset2) 
  </code></pre>
  
  <p>when the previous query returned larger amount of data, raises OLE DB Error: </p>
  
  <blockquote>
    <p><em>'Microsoft OLE DB Provider for SQL Server' Error: Cannot
    create new connection because in manual or distributed transaction mode.</em></p>
  </blockquote>
  
  <p>PS. Database settings from <code>settings.py</code>:</p>
  
  <pre><code># Database for this installation. 
  DATABASES = {
  'default':{
      'ENGINE': 'django.db.backends.sqlserver_ado', 
      'NAME': '***',                      
      'USER': '***',                      
      'PASSWORD': '***',                  
      'HOST': '***',                      
      'PORT': '',                        
      'OPTIONS' : {
          'provider': 'SQLOLEDB',
          'use_mars': True,                    
            }
  }
  }
  </code></pre>
  
  <p>PS2. I came across this issue on the google-code page of djang-mssql: <a href="http://code.google.com/p/django-mssql/issues/detail?id=79" rel="nofollow">http://code.google.com/p/django-mssql/issues/detail?id=79</a> - but it seems to be solved in new version of package...</p>
  
  <p>What can I do about it?</p>
  
  <p>Thanks in advance</p>