SQL Server 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 ‘Visual’

FIX: DTSTransferObjects with Events Generates an Error Message and an Access Violation in Visual Basic

Symptoms
This article describes one possible reason why a Data Transformation Services (DTS) package created in Microsoft Visual Basic code may fail with an error message and an access violation (AV).
When you create a DTSTransferObjectsTask task in a DTS package and specify the WITHEVENTS keyword, and you then run the DTS package from Microsoft Visual Basic code, the package may fail with the following error message:

ErrorCode: -2147221499
Source: Microsoft Data Transformation Services (DTS) Package
Description: Need to run the object to perform this operation After you set a breakpoint at the beginning of the OnProgress procedure, and you single step through your OnProgress code in Visual Basic, you will see the underlying access violation (AV):

Package failed error: x80040005, x80040000 + 5
Provider generated code execution exception: EXCEPTION_ACCESS_VIOLATION Then, Dr. Watson shows an error message similar to the following:

The instruction at “0×0fa9183f” referenced memory at “0×00000001″. The memory could not be “read”. When you run the Visual Basic application under the debugger WinDbg you will see a first chance exception of type access violation in OLEAUT32!SysAllocStringByteLen.
NOTE: This article is specifically about the OnProgress event of a DTSTransferObjectsTask!
The most common causes for the error message and access violation when you use DTS in Visual Basic applications are described in the following Microsoft Knowledge Base article:
271889?(http://support.microsoft.com/kb/271889/EN-US/) PRB: Error Message: “Exception Access Violation 2147221499.Need to run the object to perform this operation” Occurs When You Run a DTS Package in Microsoft Visual Basic Code
Resolution
To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/EN-US/) INF: How To Obtain the Latest SQL Server 2000 Service PackNOTE: The following hotfix was created before the release of Microsoft SQL Server 2000 Service Pack 3.
The English version of this fix should have the following file attributes or later:

DateTimeVersionSizeFile name————————————————————–06-Jan-200220:238.00.5661,901,120 bytesDtspkg.dll NOTE: Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.

A System.InvalidOperationException exception may occur when you try to use a Visual Studio .NET 2003 client application against a SQL Server 2005 native Web service

Symptoms
When you try to use a Microsoft Visual Studio .NET 2003 client application against a Microsoft SQL Server 2005 native Web service,a System.InvalidOperationException exception may occur.
Resolution
This problem occurs because the System.Data.DataSet object that Visual Studio .NET 2003 uses does not support the XML Schema definition language (XSD) schemas that SQL Server 2005 generates.

PRB: Choosing Quit in WFC Exception Dialog Box Shuts Down Host

Symptoms
When an ActiveX control created with Windows Foundation Classes for Java(WFC) is placed in Visual Basic and throws an exception, the default WFCexception dialog box gives you the choice to either Continue, Quit, or SeeDetails. If you click Quit, the entire process hosting the WFC controlquits.
In an application hosted by the Visual J++ Integrated DevelopmentEnvironment (IDE), this is okay because the application is running in adifferent process than the IDE. However, in Visual Basic, the IDE and theapplication are in the same process until you actually make an .exe, sochoosing Quit kills the entire Visual Basic IDE, along with any unsavedwork.
Resolution
There are two methods for resolving this issue. The first method is tonever choose Quit in the WFC exception dialog box that appears when youreceive an unhandled exception while hosting a WFC control in a VisualBasic application while running in the Visual Basic IDE. Instead, youshould always choose Continue and then shut down the Visual Basicapplication from within the Visual Basic IDE.
The second method is to add an onThreadExceptionEventHandler to your WFCActiveX control. This event handler is called instead of the default WFCexception handling routines and the default dialog box that contains theQuit option does not appear. Your WFC control, however, is responsible forhandling exceptions, notifying the user, and shutting down as necessary.
Sample CodeThe following sample code adds a very simple ThreadException Handler to aWFC ActiveX control:

// … Other WFC imports …import com.ms.wfc.app.*; // This creates the Application object.public class Control1 extends UserControl {// Define a Thread Exception Handler Delegate.private void threadException(Object sender, ThreadExceptionEvent e) {MessageBox.show(“In Exception Handler”);}public Control1() {// Add the Thread Exception Handler delegate.Application.addOnThreadException( new ThreadExceptionEventHandler(this.threadException));// Required for Visual J++ Form Designer support.initForm();}// The rest of your WFC ActiveX control goes here… (c) Microsoft Corporation 1998, All Rights Reserved. Contributions by SteveHorne, Microsoft Corporation.

How to use the My.Computer.Network object to download and upload files in Visual Basic 2005

Symptoms
Learn about how to use the My.Computer.Network object and its methods to download and upload files across a network in Microsoft Visual Basic 2005. This article contains sample steps and sample code that demonstrate how to use the My.Computer.Network object for these tasks.
Resolution
This article describes how to use the My.Computer.Network object to upload and download files across a network in Visual Basic 2005. By using this object, you can transfer files from a local computer to a remote network resource. Additionally, you can transfer files from a remote network resource to a local computer. To do this, use the following methods in a Visual Basic 2005 application: My.Computer.Network.DownloadFileMy.Computer.Network.UploadFileThe My.Computer.Network.UploadFile method sends the specified file from the local computer to the specified remote host address. The My.Computer.Network.DownloadFile method downloads the specified remote file and then saves the file in the specified location on the local computer.

FIX: You may receive Visual Basic compiler error messages when you are developing a Visual Basic 2005 project in Visual Studio 2005

Symptoms
When you are developing a Microsoft Visual Basic 2005 project in Microsoft Visual Studio 2005, you may receive the following error messages:

Visual Basic compiler is unable to recover from the following error: System Error &H8013141e& Save your work and restart Visual Studio
Microsoft(R) Visual Basic Compiler has encountered a problem and needs to close. We are sorry for the inconvenience.
The exception unknown software exception (0×800040005) occurred in the application at location xxxxxxxxYou may also receive the following error message in the Visual Studio 2005 IDE output window:

The “Vbc” task failed unexpectedly.
System.Runtime.InteropServices.COMException (0×80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Microsoft.Build.Tasks.Hosting.IVbcHostObject.EndInitialization()
at Microsoft.Build.Tasks.Vbc.InitializeHostCompiler(IVbcHostObject vbcHostObject)
at Microsoft.Build.Tasks.Vbc.InitializeHostObject()at Microsoft.Build.Utilities.ToolTask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) Additionally, you may be prompted to send error reports to Microsoft before Visual Studio 2005 will close.
Note This problem occurs more frequently when you are developing Microsoft ASP.NET projects or when you are debugging application code by using the Edit and Continue feature in the Visual Studio 2005 IDE.
Resolution
This problem is caused by a bug intheVisual Basic 2005 compiler.

FIX: Exception Error Closing an Application Containing a CoolBar Control

Symptoms
A Visual Basic application that has a CoolBar control crashes while exiting the application. This occurs when there is an End statement in the unload event of the form that hosts a CoolBar control. This behavior occurs only when running the executable and does not happen in the Visual Basic integrated development environment (IDE). The error message is similar to the following:
In the Windows 9x platform:

This program has performed an illegal operation and will be shutdown.Clicking on the Details button may reveal text similar to the following:

PROJECT1 caused an exception 10H in module MSVBVM60.DLL at 015f:66024d53.In Windows NT or Windows 2000 platform, the following error message appears:

Form1:Project1.exe – Application Error
The exception Floating-point inexact result.
(0xc000008f) occurred in the application at location 0×77f1d493.
Resolution
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected inService Pack 4 for Visual Studio 6.0.
For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:
194022?(http://support.microsoft.com/kb/194022/EN-US/) INFO: Visual Studio 6.0 Service Packs, What, Where, Why
194295?(http://support.microsoft.com/kb/194295/EN-US/) HOWTO: Tell That a Visual Studio Service Pack Is InstalledTo download the latest Visual Studio service pack, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx(http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx)