Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q301518

↑ Back to the top


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

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


Keywords: KB301518, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 301518
Revision : 4
Created on : 12/3/2003
Published on : 12/3/2003
Exists online : False
Views : 557