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
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
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
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:
- Open a new Standard EXE project in Visual Basic 5.0 or 6.0. Form1 is created by default.
- 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.
- Add a CommandButton control to Form1.
- 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
- 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
- Stop running the project, and comment out the strm.charset ="ascii" statement as follows:
- 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