Microsoft KB Archive/97082

= BUG: ODBC Getchunk Method on Non-Memo Field Causes GPF/UAE =

Article ID: 97082

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition

-



This article was previously published under Q97082



SYMPTOMS
Attempting to use the GetChunk method on a Text field or any field that has a data type other than Memo results in an unrecoverable application error (UAE) or a general protection (GP) fault.



CAUSE
The GetChunk method returns a string that represents all or a portion of a Memo field and only a Memo field in a specified dynaset.



WORKAROUND
To avoid the problem, use code to ensure that the field is a Memo field before you call the GetChunk method. For example, replace the following line shown in step 2 of the More Information section of this article: string1$ = ds(ds.Fields(NonMemoFieldNum%).Name).GetChunk(0, 50) with this code: If ds.Fields(NonMemoFieldNum%).type = 12 Then string1$ = ds(ds.Fields(NonMemoFieldNum%).Name).GetChunk(0, 50) End If



STATUS
Microsoft has confirmed this to be a bug in the Professional Edition of Microsoft Visual Basic version 2.0 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge base as it becomes available.



Steps to Reproduce 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 ds As dynaset

ServerName$ = &quot;aServerName&quot; ' Provide the name of a real server. DBName$ = &quot;aDatabase&quot;       ' Name of a database on the server. TableName$ = &quot;aTable&quot;       ' Name of a table in the database. UserName$ = &quot;aUser&quot;         ' login id      PW$ = &quot;&quot;                     ' password NonMemoFieldNum% = 1 ' This could be any field in the table that ' is not of type &quot;Memo&quot;.

'Connect to the SQL database Connect$ = &quot;UID=&quot; + UserName$ + &quot;;PWD=&quot; + PW$ + &quot;;DBQ=&quot; + DBName$

Set db = OpenDatabase(ServerName$, False, False, Connect$)

Set ds = db.CreateDynaset(TableName$) ' GP fault occurs on the following line: string1$ = ds(ds.Fields(NonMemoFieldNum%).Name).GetChunk(0, 50) End Sub  Press the F5 key or ALT+R+S, and click Form1.

This results in a GP fault usually at address 0009:08EC in VBODBCA.DLL.

Additional query words: buglist2.00 2.00 GPF

Keywords: kbbug KB97082

-

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

© Microsoft Corporation. All rights reserved.