PRB: "Can't Perform Operation on a Nontable" w/ ISAM TableDef

ID: Q126223


The information in this article applies to:
  • Microsoft Visual Basic Professional Edition for Windows, version 3.0


SYMPTOMS

If you try to add or remove a field in a TableDef object for an Installable ISAM database table (Btrieve, dBASE, FoxPro, or Paradox) that contains data, you receive error 3282:

Can't perform operation on a nontable.


CAUSE

This error message occurs when the table contains data. The Visual Basic database engine can't modify the table structure of an ISAM table if that table has data in it.


WORKAROUND

Add a new tabledef with the structure you want. Then move the records from the old table into the new, and delete the old table.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

Create and run a project that contains the following sample code. It generates the error message if MyTable contains data:

Sub Command1_Click ()
   Const DB_TEXT = 10
   Dim db As database
   Dim td As tabledef
   Dim fd As Field

   On Error Goto AppendTrap

   ' Open the database and set the tabledef
   Set db = OpenDatabase("c:\dBASE", False, False, "dBASE iii")
   Set td = db.TableDefs("MyTable")

   ' Create a new field object and append to the tabledef
   Set fd = New Field
   fd.Name = "f1"
   fd.Type = DB_TEXT
   fd.Size = 15         ' Creates a text field length 15 characters
   td.Fields.Append fd  ' Error occurs here!

   db.Close
   On Error Goto 0
   Exit Sub

AppendTrap:
   If Err = 3282 Then
      MsgBox "Cannot Modify Table - it contains data!"
      Resume Next
   Else
      MsgBox Error$
      On Error Goto 0
      Exit Sub
   End If

End Sub 

Additional query words: 3.00

Keywords :
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type :


Last Reviewed: January 25, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.