Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘information’

PRB: GetChunk Corrupts Binary Data on Win98/NT4 SP4

Symptoms
When using the Data Access Objects (DAO), Remote Data Objects (RDO) or the ADO GetChunk method, on a long binary field of a Microsoft Access database, binary data may appear corrupt if the binary information previously stored was read from disk using a String (BSTR) variable instead of a Byte array. The problem occurs under one of the following conditions:
You recently upgraded your computer to Windows 98 or Windows NT version 4.0 SP4. Previously stored data now appears corrupt.
-or-You are using a shared database. The corruption occurs when the binary data was stored by clients running on Windows 95 or Windows NT 4.0 SP3, and then extracted by clients running Windows 98 or Windows NT 4.0 SP4 or vice versa.
Resolution
The problem is that the information stored to the database is mistakenly being converted to Unicode before being stored. The “corruption” occurs when reading the information from disk using the Visual Basic or Visual Basic for Applications Get statement.
By design, the Get statement relies on the data type of the variable to determine how the information should be read into Visual Basic. If you pass a String (BSTR) variable to the function, Visual Basic identifies the information as being a text string, and converts it to Unicode. However, since the data is binary and not text, this conversion corrupts the data before it is ever stored to the database.
Although binary data stored in Unicode format can be “decoded” in some cases, it requires that the Unicode symbol table used to map 1-byte ANSI characters to 2-byte Unicode characters be the same for both the conversion to and the conversion from Unicode. Due to the recent addition of the European Currency symbol, the symbol table for Windows 98 and Windows NT 4.0 SP4 is different from those used previously. These changes will have no effect on text strings, but can effect binary data mistakenly converted to Unicode.

PRB: Error When You Access an Array Field of a .NET Structure from COM

Symptoms
When you access an Array field of a structure that is defined in .NET from inside a COM DLL, you may receive the following error message:

“An unhandled exception of type ‘System.ArgumentException’ occurred in ProjectName”
Additional information: Wrong number of arguments or invalid property assignment.
Resolution
Because of the late-bound method that is used in this case, the Visual Basic 6.0 runtime cannot get the type information for the Array field that you are attempting to access.

INFO: VB 6.0 Readme Part 7: Error Message Issues

Symptoms
The information below includes the documentation and workarounds for VisualBasic 6.0. This information can also be found in the README.htm file thatships with Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see theREFERENCES section of this article for a list of the Microsoft KnowledgeBase articles relating to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:
Part 1.Important Issues – Please Read First!
Part 2.Data Access Issues and DataBinding Tips
Part 3.Control Issues
Part 4.Language Issues
Part 5.Samples Issues
Part 6.Wizard Issues
Part 7.Error Message Issues
Part 8.WebClass Designer Issues
Part 9.DHTML Page Designer Issues
Part 10. Extensibility issues
Part 11. Miscellaneous Issues
Part 12. Microsoft Transaction Server (MTS) Issues
Part 13. Dictionary Object
Part 14. Visual Component Manager
Part 15. Application Performance Manager
Resolution
No Help Topic for the Following Error MessagesThere are currently no Help topics for the following error messages:
“Object module needs to implement ‘<name>’ for interface ‘<classname>’.”An interface is a collection of unimplemented procedure prototypes. Thiserror occurs when you specified an interface in an Implements statement,but you failed to add code for all the procedures in the interface.
You must write code for all procedures specified in the interface. An emptyprocedure containing only a comment is sufficient.
For additional information, select the item in question and press F1.
“Private Enum types and Enum types defined in standard modules orprivate classes cannot be used in public object modules as parameters orreturn types for public procedures, as public data members, or as fieldsof public user defined types.”This error occurs when you attempt to use an Enum type (or private Enumtype) as:
A parameter for a public object moduleA return type for a public procedureA public data memberFields of public user-defined typesAvoid using Enum or private Enum types in these circumstances.
“Can’t ReDim, Erase, or assign to Variant that contains array whoseelement is With object.”This error occurs when you attempt to ReDim, Erase, or assign to a Varianta variable whose element is a With object. For example, the following codewill produce this error:

Type TestName as IntegerEnd TypeSub Main()Dim c(0) As TestDim ee = cWith e(0)ReDim e(1)End WithEnd Sub

INFO: VB 6.0 Readme Part 11: Miscellaneous Issues

Symptoms
The information below includes the documentation and workarounds for VisualBasic 6.0. This information can also be found in the README.htm file thatships with Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see theREFERENCES section of this article for a list of the Microsoft KnowledgeBase articles relating to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:
Part 1.Important Issues – Please Read First!
Part 2.Data Access Issues and DataBinding Tips
Part 3.Control Issues
Part 4.Language Issues
Part 5.Samples Issues
Part 6.Wizard Issues
Part 7.Error Message Issues
Part 8.WebClass Designer Issues
Part 9.DHTML Page Designer Issues
Part 10. Extensibility issues
Part 11. Miscellaneous Issues
Part 12. Microsoft Transaction Server (MTS) Issues
Part 13. Dictionary Object
Part 14. Visual Component Manager
Part 15. Application Performance Manager
Resolution
Returning an Error Value from a DLLTo return an error value from a dynamic link library (DLL) procedure, the Clanguage prototype must be coded so that the return value is an HRESULT.Refer to the Microsoft Press OLE 2 Programmer’s Reference, Volume 2 formore information on how to do this.
Data Access Guide: DataFormats Tutorial Has Wrong File ExtensionThe topic named “Format Objects Tutorial” contains a wrong reference to afile with the extension .mdl. The actual file extension is .udl. For moreinformation, search online, with Search titles only selected, for “FormatObjects Tutorial” in the MSDN Library Visual Studio 6.0 documentation.The file in question is listed as “Northwind.mdl,” but should be”Northwind.udl.”
External Editor Field Added to Options Dialog BoxThe Advanced tab of the Options dialog box has a new text box calledExternal HTML Editor. This option allows you to select the HTML editingprogram that appears when you select Launch Editor from either the DHTMLPage Designer or the Webclass Designer. You must enter the drive, path, andexecutable name of the program you want to use. You can choose an HTMLediting program, a word processing program, or the text editor you preferto use.
CodeBase Fixup Utility in Internet Component DownloadThe “Downloading ActiveX Components” section of the Building InternetApplications book makes reference to a utility called the CodeBase FixupUtility that can be used to manually set codebase information in an ActiveXdocument. This information is incorrect. The utility is not shipped in the\Tools directory with Visual Basic, and you do not need to perform thisprocess manually for Internet Explorer 4.0 because the Package andDeployment wizard automatically inserts the appropriate codebaseinformation for these and other applicable projects.
Text in Project Properties/Open Dialogs Truncated
in Japanese, Chinese, and Korean Versions of WindowsWhen you run Visual Basic in the Japanese, Chinese, or Korean version ofWindows, you may notice that text in the Project Properties or Open dialogsis truncated. If this occurs, shut down Windows, restart it, then restartVisual Basic and the problem will be fixed.
Avoid Using Repository Add-In with ActiveX DesignersYou should avoid using the Repository add-in with projects that containActiveX designers.
For a complete list of available designers, on the Project menu in VisualBasic, click Components, and then click the Designers tab in the Componentsdialog box.

DataSet contains duplicate records based on the SQL outer join query

Symptoms
If you call the Fill method of the DataAdapter object twice on a DataTable in a DataSet that is based on a SQL outer join statement, if you do not first clear the current contents of the DataTable, the DataTable may contain two copies of each record.
Resolution
The records are duplicated because a DataTable that is based on a SQL outer join query does not contain primary key information to identify each record uniquely. Instead of merging with the existing records based on key information, a second set of exactly the same records is appended.