Microsoft KB Archive/94773

= FIX: Attempting to Refresh Null TableDef Field Causes GP Fault =

Article ID: 94773

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition

-



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:

&quot;Method not applicable to this object.&quot;

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:

 Start the Professional Edition of VB.EXE with ODBC support already installed.  Add the following code to the Form_Click event procedure of Form1: Form_Click Dim db As Database Dim tDef As TableDef DBName$ = &quot;Server1&quot; 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.  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 query words: 2.00 3.00 GPF buglist2.00 fixlist3.00

Keywords: kbbug kbfix KB94773

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.