PRB: Connection Busy Error with a Shared Connection (191343)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
- Microsoft Data Access Components 2.5
This article was previously published under Q191343 SYMPTOMS
Attempting to issue a CREATE SQL VIEW, USE or REQUERY() command with a
REMOTE VIEW, results in the following error message:
Connection CONNECTION_NAME is busy.
This behavior occurs under the following conditions:
- Two or more Remote Views are created using the same SHARED connection.
- The MAXRECORDS property of at least one of the VIEWS is set to a value
greater than 0.
- The FETCHSIZE property of at least one of the VIEWS is set to a value
greater than 0.
- The FETCHSIZE property value is less than or equal to the MAXRECORDS
property value.
RESOLUTION
Here are the workarounds for this problem:
- Do not include the SHARED clause in the CREATE SQL VIEW command used to create the remote view:
CREATE SQL VIEW "MYVIEW1" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_a
DBSETPROP('MYVIEW1', 'View', 'FetchSize', 1)
DBSETPROP('MYVIEW1', 'View', 'MaxRecords', 1)
USE MYVIEW1 IN 0
CREATE SQL VIEW "MYVIEW2" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_b
DBSETPROP('MYVIEW2', 'View', 'FetchSize', 1)
DBSETPROP('MYVIEW2', 'View', 'MaxRecords', 1)
- Create a separate connection for each of the views:
CREATE CONNECTION CONN1 DATASOURCE 'CONNECT' USERID 'SA' PASSWORD ''
CREATE CONNECTION CONN2 DATASOURCE 'CONNECT' USERID 'SA' PASSWORD ''
CREATE SQL VIEW "MYVIEW1" ;
REMOTE CONNECT "CONN1" SHARED ;
AS SELECT * ;
FROM mytable_a
DBSETPROP('MYVIEW1', 'View', 'FetchSize', 1)
DBSETPROP('MYVIEW1', 'View', 'MaxRecords', 1)
USE MYVIEW1 IN 0
CREATE SQL VIEW "MYVIEW2" ;
REMOTE CONNECT "CONN2" SHARED ;
AS SELECT * ;
FROM mytable_b
DBSETPROP('MYVIEW2', 'View', 'FetchSize', 1)
DBSETPROP('MYVIEW2', 'View', 'MaxRecords', 1)
- Use the default MAXRECORDS and FETCHSIZE properties:
CREATE SQL VIEW "MYVIEW1" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_a
USE MYVIEW1 IN 0
CREATE SQL VIEW "MYVIEW2" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_b
- Set the FETCHSIZE property of the view(s) to -1 (ALL):
CREATE SQL VIEW "MYVIEW1" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_a
DBSETPROP('MYVIEW1', 'View', 'MaxRecords', 1)
DBSETPROP('MYVIEW1','View','Fetchsize',-1)
USE MYVIEW1 IN 0
CREATE SQL VIEW "MYVIEW2" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_b
DBSETPROP('MYVIEW2', 'View', 'MaxRecords', 1)
DBSETPROP('MYVIEW2','View','Fetchsize',-1)
- Set the FETCHSIZE property of the view(s) to any value that is greater than the value returned by the expression:
DBGETPROP('View Name','View','MaxRecords')
CREATE SQL VIEW "MYVIEW1" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_a
DBSETPROP('MYVIEW1', 'View', 'MaxRecords', 1)
maxrecs=DBGETPROP('MYVIEW1','View','MaxRecords')+1
DBSETPROP('MYVIEW1','View','Fetchsize',maxrecs)
USE MYVIEW1 IN 0
CREATE SQL VIEW "MYVIEW2" ;
REMOTE CONNECT "CONN1" ;
AS SELECT * ;
FROM mytable_b
DBSETPROP('MYVIEW2', 'View', 'MaxRecords', 1)
maxrecs=DBGETPROP('MYVIEW2','View','MaxRecords')+1
DBSETPROP('MYVIEW2','View','Fetchsize',maxrecs)
STATUS
The behavior is by design.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
178760 HOWTO: Alter the Properties of a View at Run Time
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by
John Desch, Microsoft Corporation
Modification Type: | Minor | Last Reviewed: | 3/3/2005 |
---|
Keywords: | kbcode kbDatabase kbprb KB191343 |
---|
|