Microsoft KB Archive/301518

= BUG: WriteText Method Fails If You Set the charset Property of the ADO Stream Object to ASCII =

Article ID: 301518

Article Last Modified on 12/3/2003

-

APPLIES TO

 Microsoft Data Access Components 2.6, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 98 Standard Edition  Microsoft ActiveX Data Objects 2.6, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q301518

<div class="symptoms_section">

SYMPTOMS
The WriteText method of an ADO Stream object whose charset property is set to ascii fails after you install Microsoft Data Access Components (MDAC) 2.6 on a computer that is running Microsoft Windows 98, Windows NT 4.0 Workstation, or Windows NT 4.0 Server. This problem does not occur on computers that are running Windows 2000 or Windows Millennium Edition (Me).

<div class="resolution_section">

RESOLUTION
To work around this problem, do not explicitly set the charset property of the ADODB.Stream object to ascii. The default setting for this property (Unicode) works consistently on all of the Microsoft Windows platforms.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
To reproduce this problem, follow these steps on a computer that is running Windows 98 or Windows NT 4.0 with MDAC 2.6: <ol> Open a new Standard EXE project in Visual Basic 5.0 or 6.0. Form1 is created by default.</li> From the Project menu, click References, and select the Microsoft ActiveX Data Objects 2.5 Library or Microsoft ActiveX Data Object 2.6 Library check box.</li> Add a CommandButton control to Form1.</li>  Paste the following code in the Click event procedure of the Command button: Dim strm as ADODB.Stream Set strm = New ADODB.Stream

strm.Open strm.Type = adTypeText strm.charset = &quot;ascii&quot;

strm.WriteText &quot;Hello World&quot;

strm.position = 0 Debug.print strm.ReadText

strm.Close Set strm = Nothing </li>  Save and run the project. Click Command1 when Form1 is displayed to run the preceding code. Notice that the Debug.Print statement to write out the text that is written into the Stream object using the WriteText method generates a blank string.

Workaround
</li>  Stop running the project, and comment out the strm.charset =&quot;ascii&quot; statement as follows: 'strm.charset = &quot;ascii&quot; </li> Save and run the project. Click Command1. Notice that the text that is written to the Stream object is displayed in the Visual Basic Debug window correctly.</li></ol>

Additional query words: WriteText execute

Keywords: kbbug kbpending KB301518

-

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

© Microsoft Corporation. All rights reserved.