PRB: CreateDynaset Err: Can't open any more tables or queries (113388)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 3.0
  • Microsoft Visual Basic Professional Edition for Windows 3.0

This article was previously published under Q113388

SYMPTOMS

After using the CreateDynaset method several times to create a dynaset from the dynaset itself, you will receive this error:
Can't open any more tables or queries.
Most often, you would be using the Sort or Filter property in this process. However, it is not necessary to do this to re-create the problem.

CAUSE

The number of times a dynaset can be created from itself is limited in the current design of Visual Basic.

WORKAROUND

To work around the problem, base all sorts or filters off of a different dynaset. The following example illustrates this:

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. Add a command button (Command1) and a text box (Text1) to the form.
  3. Add the following code in the command click event.
       Sub Command1_Click()
          Dim db As Database
          Dim ds As Dynaset
          Dim ds2 As Dynaset
          Set db = OpenDatabase("C:\VB\BIBLIO.MDB")
          Set ds = db.CreateDynaset("SELECT * FROM Authors")
          Set ds2 = ds
          Do
             iCount = iCount + 1
             Text1.Text = iCount
             ds2.Sort = "Author"
             Set ds = ds2.CreateDynaset()
          Loop
       End Sub
    						
  4. Run the program or press the F5 key.
The problem does not occur with snapshot objects.

STATUS

This behavior is by design in Visual Basic version 3.0 for Windows. However, Microsoft is considering a change for future releases.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.
  2. Add a command button (Command1) and a text box (Text1) to the form.
  3. Add the following code in the Command1 click event:
       Sub Command1_Click()
          Dim db As Database
          Dim ds As Dynaset
          Set db = OpenDatabase("C:\VB\BIBLIO.MDB")
          Set ds = db.CreateDynaset("SELECT * FROM Authors")
          Do
             iCount = iCount + 1
             Text1.Text = iCount
             Set ds = ds.CreateDynaset()
          Loop
       End Sub
    						
  4. Run the code. The error should occur on the tenth iteration.

Modification Type:MajorLast Reviewed:10/30/2003
Keywords:kbprb KB113388