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 for March, 2010

PRB: 32-bit BASIC Does Not Convert UNICODE/ANSI in Binary Field

Symptoms
When using a binary field to store text in a Microsoft Jet 2.5 or earlierdatabase, 32-bit applications cannot read text written by 16-bitapplications and vice versa.
Resolution
Unlike Memo fields, the 32-bit programs do no automatic ANSI/UNICODEconversion on binary fields.

PRB: “Unable to Display Help” or “No Help Available” Error Messages for ADO from Within Visual Basic

Symptoms
When you try to access ActiveX Data Objects (ADO) documentation from within Visual Basic by pressing F1 from the code editor or from within the object browser, nothing occurs, or you receive one of the following error messages:

Unable to display help
-or-

No help available
Resolution
This problem occurs because the following items must exist to access context-sensitive help for ADO in the Visual Basic IDE: The correct version of the ADO compiled HTML help file that corresponds to the ADO version that is referenced in the project references. -and-
An entry in the registry that lists this ADO compiled HTML help file as an available HTML help file. This problem is known to occur when one or both of these items are missing.

PRB: “Too Many Columns Defined in the Rowset” Error Message

Symptoms
Running under versions of Microsoft Data Access Components (MDAC) prior to 2.5, you get the following error when choosing a Recordset object:

Run-time error ‘-2147024882 (8007000e)’Too many columns defined in the rowset.Running under MDAC 2.5 and later, you get the following error:

Run-time error ‘-2147024882 (8007000e)’:Rowsets cannot contain more than 2048 columns.
Resolution
Prior to MDAC 2.5, the client-cursor engine supported a maximum of 255 fields.
Under MDAC versions 2.5 and later, the client-cursor engine supports a maximum of 2048 fields.

PRB: “System.Messaging.MessageQueueException” Error Message When You Run the MessageQueue.Send Method MSDN Sample Code or When You Run the MessageQueue.Receive Method MSDN Sample Code

Symptoms
When you run the sample code that appears on certain Microsoft Developer Network (MSDN) Web sites, you may receive the following error message:

An unhandled exception of type ‘System.Messaging.MessageQueueException’ occurred in system.messaging.dll
Additional information: External component has thrown an exception.The following MSDN Web sites are affected:
MessageQueue.Send Method
http://msdn2.microsoft.com/en-us/library/system.messaging.messagequeue.send(vs.71).aspx(http://msdn2.microsoft.com/en-us/library/system.messaging.messagequeue.send(vs.71).aspx)
MessageQueue.Send Method (Object)
http://msdn2.microsoft.com/en-us/library/aa329510(VS.71).aspx(http://msdn2.microsoft.com/en-us/library/aa329510(VS.71).aspx)
MessageQueue.Send Method (Object, MessageQueueTransaction)
http://msdn2.microsoft.com/en-us/library/aa329511(VS.71).aspx(http://msdn2.microsoft.com/en-us/library/aa329511(VS.71).aspx)
MessageQueue.Receive Method
http://msdn2.microsoft.com/en-us/library/system.messaging.messagequeue.receive(vs.71).aspx(http://msdn2.microsoft.com/en-us/library/system.messaging.messagequeue.receive(vs.71).aspx)
MessageQueue.Receive Method (MessageQueueTransaction)
http://msdn2.microsoft.com/en-us/library/aa329505(VS.71).aspx(http://msdn2.microsoft.com/en-us/library/aa329505(VS.71).aspx)
MessageQueue.Receive Method (TimeSpan, MessageQueueTransaction)
http://msdn2.microsoft.com/en-us/library/aa329508(VS.71).aspx(http://msdn2.microsoft.com/en-us/library/aa329508(VS.71).aspx)
Resolution
The sample code that appears on these MSDN Web sites contains the following code that may cause you to receive the System.Messaging.MessageQueueException error message.
Microsoft Visual Basic .NET

myQueue.Send(“My Message Data.”, New _MessageQueueTransaction())Microsoft Visual C# .NET

myQueue.Send(“My Message Data.”, newMessageQueueTransaction());Microsoft Visual C++ .NET

myQueue->Send(S”My Message Data.”, new MessageQueueTransaction());You receive the error message because the call to the myQueue.Send method uses a MessageQueueTransaction object without starting a transaction. Additionally, even if you start a transaction before calling the myQueue.Send method, your application may wait indefinitely to receive the sent message. However, your application does not receive a sent message unless the corresponding transaction is committed.
Note The MessageQueue.Send(Object, MessageQueueTransaction) method applies only to transactional queues. Therefore, you receive the error message that is mentioned in the “Symptoms” sectiononly if you use transactional queues.

PRB: “Requested Registry Access Is Not Allowed” Error Message When ASP.NET Application Tries to Write New EventSource in the EventLog

Symptoms
When you use ASP.NET to create a new event source in the event log, you may receive the following error message:

System.Security.SecurityException: Requested registry access is not allowed.
Resolution
By default, the user token of the ASP.NET worker process is ASPNET (or NetworkService for applications that run on Internet Information Services [IIS] 6.0). The problem in the “Symptoms” section occurs because your account does not have the correct user rights to create an event source.

PRB: “Operation Must Use an Updateable Query” Error Message When You Access Excel Through ODBC

Symptoms
When you edit an Excel worksheet through ADO and ODBC, you may receive the following error message if you use an ADO DataControl object:

[Microsoft][ODBC Excel Driver] Operation must use an updateable query.If you use a Recordset object that is generated with ADO code, you may receive the following error message when you edit an Excel worksheet through ADO and ODBC:

Run-time error ‘-2147467259(80004005)’:[Microsoft][ODBC Excel Driver] Operation must use an updateable query.
Resolution
This problem occurs if you try to edit a worksheet that is saved or opened as ReadOnly.
NOTE: ReadOnly is the default setting for an ODBC connection to Excel, with or without a data source name (DSN). Therefore, the user must always change that setting to edit data.