FIX: Application Terminates When the Depth of SHAPE Command Child Recordset is Large (818521)



The information in this article applies to:

  • Microsoft Data Access Components
  • ActiveX Data Objects (ADO)

SYMPTOMS

When you increase the depth of the child recordset in a SHAPE command object by adding large number of recordsets, your application may quit unexpectedly.

CAUSE

The application quits unexpectedly because the relationship between the recordset is established recursively, and recursion depth is not controlled. When the uncontrolled recursion stack overflows, the application quits.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Basic 6.0. On the File menu, click New Project. In the New Project dialog box, click Standard Exe. By default, Form1 is created.
  2. On the Project menu, click References. Click Microsoft ActiveX Data Objects 2.7 Library and then click OK.
  3. Double-click Form1 to open the code view for Form_Load. Add the following code to the Form1_Load event.
    Private Sub Form_Load()
       Dim cn As New Connection
       Dim rs As New Recordset
       Dim str As String
       Dim shapestr1  As String
       Dim i As Integer
    
       cn.Open "Provider=MSDataShape;Data Provider=SQLOLEDB;User ID=sa;Persist Security Info=False;Initial Catalog=Northwind;Data source=10.150.144.131"
       
       On Error Resume Next
       
       cn.Execute ("DROP TABLE F1")
       cn.Execute ("CREATE TABLE F1 (id INT PRIMARY KEY, name VARCHAR (255))")
       cn.Execute ("INSERT INTO F1 (id, name) VALUES (1, '11111111111')")
       cn.Execute ("INSERT INTO F1 (id, name) VALUES (2, '22222222222')")
       cn.Execute ("INSERT INTO F1 (id, name) VALUES (3, '33333333333')")
       cn.Execute ("INSERT INTO F1 (id, name) VALUES (4, '44444444444')")
       cn.Execute ("INSERT INTO F1 (id, name) VALUES (5, '55555555555')")
       
       cn.Execute ("DROP TABLE F2")
       cn.Execute ("CREATE TABLE F2 (idx INT PRIMARY KEY, title VARCHAR (255))")
       cn.Execute ("INSERT INTO F2 (idx, title) VALUES (1, '11111111111')")
       cn.Execute ("INSERT INTO F2 (idx, title) VALUES (2, '22222222222')")
       cn.Execute ("INSERT INTO F2 (idx, title) VALUES (3, '33333333333')")
       cn.Execute ("INSERT INTO F2 (idx, title) VALUES (4, '44444444444')")
       cn.Execute ("INSERT INTO F2 (idx, title) VALUES (5, '55555555555')")
       
       On Error GoTo ErrHandler
          
       Dim hapestr1 As String, shapestr2 As String
          
       
       ' Construct SHAPE command
       shapestr1 = "SHAPE {select * from F1} APPEND ("
       shapestr2 = "RELATE id TO id) "
       For i = 2 To 11000
          shapestr1 = shapestr1 + "(SHAPE {select * from F1} APPEND ("
          shapestr2 = "RELATE id TO id)) " + shapestr2
       Next
       shapestr1 = shapestr1 + "{select * from F1} "
       
       shapestr1 = shapestr1 + shapestr2
       
       ' Try to open the recordset
       rs.Open shapestr1, cn, adOpenDynamic, adLockBatchOptimistic, -1
       rs.Close
       
       Exit Sub
       
    ErrHandler:
       MsgBox "Error Number: " & Err.Number
       MsgBox "Error Description: " & Err.Description
       
    End Sub
    
  4. On the Run menu, click Start.
The application stops responding and the Visual Basic instance terminates automatically.

REFERENCES

For more information about Data Access Technologies, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:5/8/2003
Keywords:kbfix kbDatabase kbSQLProg kbDataObject kbbug KB818521 kbAudDeveloper