Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access ODBC to SQL Server 'Connection busy with results from another command'

Posted on 2011-09-26
7
3,303 Views
Last Modified: 2012-06-22
I have been working on an Access front-end to a SQL Server 2008 Express database. I have a main form with several sub-forms and after adding a further couple of sub-forms today, I find whenever I try to add a new record. This only happens with the new subforms, the existing ones being OK. The message is as follows..

ODBC Call failed.
[Microsoft][SQL Server Native Client 10.0]Connection is busy with results from another command (#0)


This seems to be a fairly common problem on the 'net although I've yet to find a solution. The subforms in question are very basic forms based on simple tables with no specific code involved so I cannot understand the issue. I think I read somewhere previously that adding a timestamp field can help although this hasn't in this case.

Any help appreciated.
0
Comment
Question by:nigelr99
  • 3
  • 3
7 Comments
 
LVL 3

Expert Comment

by:_-W-_
ID: 36601275
Instead DAO.Recordset use ADODB.Recordset? Also, try turning on MARS.

Using MARS from ODBC and OLE DB
To use MARS with ODBC the connection string addition is “MARS_Connection=yes”, or you can a connection attribute as follows:
    SQLSetConnectAttr(hdbc, SQL_COPT_SS_MARS_ENABLED,SQL_MARS_ENABLED_YES, SQL_IS_UINTEGER);
before calling SQLDriverConnect or SQLBrowseConnect. With OLE DB, the provider string addition for IDBInitialize::Initialize is “MarsConn=yes”, or “MARS Connection=true” if you use an initialization string with IDataInitialize::GetDataSource. You can also enable MARS programmatically as follows:

    IDBInitialize *pIDBInitialize = NULL;
    IDBProperties *pIDBProperties = NULL;
    // Create the data source object.
    hr = CoCreateInstance(CLSID_SQLNCLI, NULL, CLSCTX_INPROC_SERVER,IID_IDBInitialize, (void**)&pIDBInitialize);
    hr = pIDBInitialize->QueryInterface(IID_IDBProperties, (void**)&pIDBProperties);

    // Set the MARS property.
    DBPROP rgPropMARS;
    IDBProperties rgPropMARS.dwPropertyID = SSPROP_INIT_MARSCONNECTION;
    rgPropMARS.dwOptions = DBPROPOPTIONS_REQUIRED;
    rgPropMARS.dwStatus = DBPROPSTATUS_OK;
    rgPropMARS.colid = DB_NULLID;
    V_VT(&(rgPropMARS.vValue)) = VT_BOOL;
    V_BOOL(&(rgPropMARS.vValue)) = VARIANT_TRUE;

    // Create the structure containing the properties.
    DBPROPSET PropSet;
    PropSet.rgProperties = &rgPropMARS;
    PropSet.cProperties = 1;
    PropSet.guidPropertySet = DBPROPSET_SQLSERVERDBINIT;

    // Get an IDBProperties pointer and set the initialization properties.
    pIDBProperties->SetProperties(1, &PropSet);
    pIDBProperties->Release();
    // Initialize the data source object.
    hr = pIDBInitialize->Initialize();
0
 

Accepted Solution

by:
nigelr99 earned 0 total points
ID: 36601768
Thanks for the response.. with it being somewhat intimidating as I'm using DSN for database connectivity and keeping things as simple as possible, I looked at this issue again. It turns out that by simply setting a check-box on the sub-form to a default value of 0 (thereby preventing a null value causing an error), the 'busy' error has gone!

Looks like the odbc error was a red herring when in fact the real problem was attempting to write a null value into a field where I've disallowed nulls?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36642041
"The subforms in question are very basic forms based on simple tables with no specific code involved so I cannot understand the issue."

"I have a main form with several sub-forms and after adding a further couple of sub-forms today,"

So your main form possibly contains more that 4 subforms?

Can you explain the purpose of this main form that it needs possibly over 4 subforms?
Are the subform related "vertically" (multiple Nested subforms), or horizontally (one man form and many subforms at the same level below the main form)

Typically you will have a main form and possibly two subforms, but not more than that because it can become confusing for the user (and the developer)
My theory here is the complexity of the form(s) may be contributing to the error (as I have never gotten this error in my multiform basic setups)

"I think I read somewhere previously that adding a timestamp field can help "
Yes, and also make sure to have a primary key in each table.

Finally, Access contains a few settings that you can use to manage possible "Timing" issues like this.
(see attached screenshot)


JeffCoachman
untitled.JPG
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:nigelr99
ID: 36709504
Well, bit of a long story, but the main form is not linked to any of the subforms.. it originally started life as a simple 'admin' form with a few subforms to view/edit some basic tables. I had a simple button interface to show / hide one subform at a time.
This has grown beyond it's original idea so I'll be looking to redesign, especially in light of odbc issues etc.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36710296
OK

Then first create the simple main form and test.
Then add one form at a time until the issuse appears.

"but the main form is not linked to any of the subforms.. it originally started life as a simple 'admin' form with a few subforms to view/edit some basic tables."
Then simply create one form for each table and use a "Menu form" to open each one individually.
  "Keep it simple"

;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36714513
If you build the individual forms, you can use the "switchboard manager" in access to create a "Menu" system.
0
 

Author Closing Comment

by:nigelr99
ID: 37023075
Null field value seemed to be causing the error so I think we can close the question. Thanks for further help from everyone.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question