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



The information in this article applies to:

  • Microsoft Data Access Components 2.6, when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 98
  • ActiveX Data Objects (ADO) 2.6, when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 98

This article was previously published under Q301518

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).

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.

STATUS

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

MORE INFORMATION

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:
  1. Open a new Standard EXE project in Visual Basic 5.0 or 6.0. Form1 is created by default.
  2. 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.
  3. Add a CommandButton control to Form1.
  4. 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 = "ascii" 
    
    strm.WriteText "Hello World"
    
    strm.position = 0
    Debug.print strm.ReadText
    
    strm.Close
    Set strm = Nothing 
    					
  5. 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

  6. Stop running the project, and comment out the strm.charset ="ascii" statement as follows:
    'strm.charset = "ascii"
    					
  7. 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.

Modification Type:MajorLast Reviewed:12/3/2003
Keywords:kbBug kbpending KB301518