FIX: Attempting to Refresh Null TableDef Field Causes GP Fault

Last reviewed: October 30, 1997
Article ID: Q94773
2.00 WINDOWS kbinterop kbprg kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 2.0

SYMPTOMS

A general protection (GP) fault occurs when you attempt to refresh a Null Fields collection of a TableDef. Instead, you should receive this error: "Method not applicable to this object."

When the Fields collection for a TableDef is not Null, the Refresh method works as expected.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Visual Basic version 2.0 for Windows. This problem was corrected in Microsoft Visual Basic version 3.0 for Windows.

MORE INFORMATION

The following steps reproduce the problem:

  1. Start the Professional Edition of VB.EXE with ODBC support already installed.

  2. Add the following code to the Form_Click event procedure of Form1:

    Form_Click () Dim db As Database Dim tDef As TableDef DBName$ = "Server1"

       Set db = OpenDatabase(DBName$)   '* DBName$ name of Database
                                        '* that is already setup on
                                        '* the SQL Server. This
                                        '* DBName$ should be set to
                                        '* server name that listed in
                                        '* the ODBC.INI file.
       Set tDef = db.TableDefs(0)
    
       Set db = OpenDatabase(DBName$)
       tDef.Fields.Refresh      '* This should result in a
                                '* error, but instead results
                                '* in a GP Fault.
       End Sub
    
       In order to reproduce the problem, the first TableDef in the database,
       TableDefs(0), cannot have any fields associated with it.
    
    

  3. Press the F5 key or ALT+R+S.

At this point, a GP fault occurs -- usually at address 0008:0083 in VBODBCA.DLL.

To avoid the problem, make sure the Fields collection is not Null before using the Refresh method. To do this, replace the tDef.Fields.Refresh statement in step 2 above with the following code:

   If Not tDef.Fields = Null Then
      tDef.Fields.Refresh
   End If


Additional reference words: 2.00 3.00 GPF buglist2.00 fixlist3.00
KBCategory: kbinterop kbprg kbbuglist
KBSubcategory: APrgDataODBC
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.