FIX: Attempting to Refresh Null TableDef Field Causes GP Fault (94773)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 2.0

This article was previously published under Q94773

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
				

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:kbbug KB94773