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 July, 2010

BUG: One or more columns in the Results pane appear to be empty when you retrieve data in Visual Studio .NET or Visual Studio 2005

Symptoms
In Microsoft Visual Studio .NET or Visual Studio 2005, one or more columns in the Results pane appear to be empty when you retrieve data from a Microsoft SQL Server 2000 database table. This problem occurs when the following conditions are true:The database table contains a column of type CHAR, NCHAR, VARCHAR, or NVARCHAR.The column contains data that has more than 900 characters.
Resolution
The cells of the Results pane in Visual Studio .NET or Visual Studio 2005 cannot display data that has more than 900 characters.

BUG: No Data Source Name Generates Run-Time Error Using RDC

Symptoms
When using Microsoft’s Remote Data Control 2.0 (RDC) without a User orSystem DSN in the ODBC Data Source Administrator, trying to set the RDC’sDataSourceName property generates a run-time error.
Resolution
Create a DSN under ODBC or upgrade from MSRDC20.ocx version 5.00.3714 (or5.01.4319), which is “Microsoft Remote Data Control 2.0,” to MSRDC20.ocxversion 6.00.816, which is “Microsoft Remote Data Control 6.0.”

BUG: Multiple SendKeys Statement Turns Off NumLock Key

Symptoms
Executing at least two SendKeys statements in a row results in turning offthe NumLock key. This problem may also affect the CapsLock and ScrollLockkeys.
Resolution
This problem deals with a nesting of capturing the keyboard state. Thefirst SendKeys statement takes a snapshot of the keyboard state and turnsoff all toggles. The second SendKeys statement executes before the firstone played out all keys and restored the keyboard state. So, the keyboardstate is recorded again by the second SendKeys, this time with all togglesstill off. Eventually, the keyboard state is restored to the later state(toggles off).

BUG: MSChart Control Can’t Plot Data Points >15 Decimal Places

Symptoms
When the Chart Control is assigned an array of data points containing 16 ormore decimal places, those data points do not appear when the chart isupdated.
Resolution
There are two ways to deal with this issue:
Formatting the number to 15 or fewer decimal places.Using the SetData property on each data point.
Workaround 1Before setting the chart to the variant array, “truncate” the decimalvalues to 15 places or less as seen in the form_load event below:

Private Sub Form_Load()Dim data_pts(1 To 3, 1 To 2) As Variantdim i as integerdata_pts(1, 1) = “R1″data_pts(1, 2) = 5.48487730596136E-02data_pts(2, 1) = “R2″data_pts(2, 2) = 7.04216678154124E-02data_pts(3, 1) = “R3″data_pts(3, 2) = 3.10863837084563E-04For i = 1 To 3data_pts(i, 2) = CDbl(Format(data_pts(i, 2), “0.000000000000000″))’Truncate data_pts to 15 decimal places of precisionNextMSChart1 = data_ptsEnd Sub
Workaround 2Use the SetData method to add the data to the chart instead of setting thechart to the variant array. To use this workaround, rewrite the Form_Loadevent to look like this instead:

Private Sub Form_Load()With MSChart1.RowCount = 3.ColumnCount = 1.DataGrid.SetData 1, 1, 5.48487730596136E-02, False.DataGrid.SetData 2, 1, 7.04216678154124E-02, False.DataGrid.SetData 3, 1, 3.10863837084563E-04, FalseEnd WithEnd Sub

BUG: Font Changes After Open Stored Procedure in Data View

Symptoms
When you open a Data View Stored Procedure Design window, the font of theData View window changes to the font of the Code window.
Resolution
To restore the font, you have to exit Visual Basic and restart.

BUG: Expanding Stored Procedures in Data View Window Causes GPF

Symptoms
Clicking the plus sign to expand a stored procedure in the Data View window in either Visual Basic, Visual InterDev, or Visual J++ generates the following error message if the stored procedure contains calls to extended stored procedures that return something other than 0 or 1, such as xp_cmdshell:

Devenv.exe – Application ErrorThe instruction at “0×412406f3″ referenced memory at “0×00000006″. The memory could not be “read”.
Resolution
Clicking the plus sign executes the stored procedure to enumerate the parameters and tables for the stored procedure. When the data environment tries to execute xp_cmdshell it generates an error.
NOTE: This problem does not occur with SQL Server 7.0 or later. It also does not occur under a Microsoft Windows 2000 environment.