Thursday, November 19, 2009

XML Error- A semi colon character was expected. Error processing resource –

1) XML Error: A semi colon character was expected. Error processing resource –

Error Description:

While  viewing  the xml file in a web browser, sometimes an error "A semi colon character was expected." Occurs.

Example of a  XML snippet  that throws this error:

<NODES>

<NODE Caption="Ext Link" Link Name="http://google.com/ccc?key=0AEeVE& hl=en" />

</NODES>

Reason:

This occurs when using external links on the XSLT sheet which contains the character “&”.

Solution:

The work around is to simply replace every instance of & in the link with &amp;

<NODES>

<NODE Caption="Ext Link" Link Name="http://google.com/ccc?key=0AEeVE&amp;hl=en" />

</NODES>

.NET Error: Operator '<operatorname>' is not defined for types '<typename1>' and '<typename2>'

Error Description:

The error "Operator '<operatorname>' is not defined for types '<typename1>' and '<typename2>'" occurs When an attempt was made to use an operator in a way that is inappropriate for the specified types.

Reason:

This error can be caused by using the "=" operator instead of using the Is operator to compare two objects.


 

Example:


 

Private Sub toolBar_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)


If e.Button = toolBarButtonNew
Then ' => Error Operator '=' is not defined for types 'System.Windows.Forms.ToolBarButton' and 'System.Windows.Forms.ToolBarButton'

      menuItemNew_Click(Nothing, Nothing)

End If

 

If e.Button <> toolBarButtonSave
Then ' => Error Operator '<>' is not defined for types 'System.Windows.Forms.ToolBarButton' and 'System.Windows.Forms.ToolBarButton'

menuItemNew_Click(Nothing, Nothing)

End
If

 

End Sub

 

Solutions:

  1. Use Is operator to compare two reference types.
  2. Use the Not operator in conjunction with the Is operator to denote inequality. 

Replace


  1. "If e.Button = toolBarButtonNew
    Then"
    with "If e.Button Is toolBarButtonNew
    Then"

  2. "If e.Button <> toolBarButtonSave
    Then"
    with "If Not e.Button Is toolBarButtonSave
    Then"

.NET Error: Implementing property must have matching 'Readonly' or 'Writeonly' specifiers

Error Description:

The compiler error Implementing property must have matching 'Readonly' or 'Writeonly' specifiers occurs When implementing property of the interface in the class.


Example:
Interface IComparer 

Public Interface IComparer


#Region "Methods"


Private Function Compare(ByVal x As [Object], ByVal y As [Object]) As
Integer

……

#End Region

End Interface


 

Class Implements the property Compare of IComparer interface:

Public Class DateTimeReverserClass

Implements IComparer

Private Function Compare(ByVal x As [Object], ByVal y As [Object]) As
Integer //=> Error throws here

Dim dx As DateTime = DirectCast(x, DateTime)
Dim dy As DateTime = DirectCast(y, DateTime)
If dx > dy Then
   Return -1
Else
   Return 1
EndIf

End Function

End Class

Reason:
The compiler is not able to find the matching property implementation on interface 'IComparer'
 

Possible Solutions:

The work around is to include the Implements clause to give the fully qualified name of the property (Format: Implements <Interface Name>.<Property Name>)

 

In the above example, replace the line "Private Function Compare(ByVal x As [Object], ByVal y As [Object]) As Integer" with "Private Function Compare(ByVal x As [Object], ByVal y As [Object]) As Integer Implements IComparer.Compare"


 Public Class DateTimeReverserClass

Implements IComparer


Private Function Compare(ByVal x As [Object], ByVal y As [Object]) As
Integer Implements IComparer.Compare

Dim dx As DateTime = DirectCast(x, DateTime)

Dim dy As DateTime = DirectCast(y, DateTime)

If dx > dy Then
Return -1
Else
Return 1

EndIf

End Function

End Class


 

Now the compiler error will not occur.

SqlBulkCopy Error: The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column.

 

Error Description:

The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column.

Reason:

The error occurs during sqlbulkcopy when the destination table contains the Decimal column with same precision and scale. (E.g., The  table in SQLServer has column TestColumn  Decimal (3,3) )

SELECT (cast(0.000 as decimal(3,3))) this will run fine in SQL, but will fail in bulk copy.

Possible Solutions:

Increase the precision size.

I had the same problem when I worked on my data migration project.

The work around was to increase the precision size by 1 if both the precision and scale are same for the Decimal Column type.

Example:

TestColumn Decimal (3,3) will fail in sql bulk copy.

But

TestColumn Decimal (3, 4) will work fine in sql bulk copy.

Tuesday, November 17, 2009

32-bit Driver Installation for 64‑bit Platforms

How to use a 32-bit driver program in 64‑bit Windows family of operating systems.

This information applies for the following operating systems:

Windows Server 2008 64-Bit Edition

Back Ground

I having been of late developing a Soft ware package in .NET Framework 3.5 for the LegaSync Project, to migrate the data from various legacy ERP systems (SAP,SYTELINE,MACPAC,MANMAN,JDE etc) to SQL server. The ODBC connectivity is used to retrieve the data from many of these legacy systems. Thus it involves various ODBC drivers, which all of them are designed for 32-bit platforms.

The initial development server that was hosted by the client was a 32-bit machine and we didn’t have any driver issues while connecting to the legacy systems.

But when it came to production deployment, the client had hosted a server with the latest configuration ( Windows Server 2008 R2, which was a 64 bit machine.)

It was then we came across this situation that 64-bit drivers need to be installed in the 64-bit machine.

But there are no 64-bit ODBC drivers available for those legacy systems in the market.

So we were in the situation that we need to install the existing 32-bit drivers in the 64-bit platform.

It was not possible to install legacy 32-bit installers to work on 64-bit Windows simply by running the installer package. The installer displays an informative error message.

The below trick cracked the issue of the installation of 32-bit driver in 64-bit platform.

Installation Considerations for 64-bit Platforms

Installation of 32-bit drivers in 64-bit platforms involves the following steps:

1) Creation of DTS Package (DTSPkg1.dtsx) using SQL Server Business Intelligence Development Studio, Which will internally run the required setup exe.

2) The DTS package needs to be run in the 32-bit windows. (default 64-bit)

3) So I used dtexec.exe, an application which can launch the application/DTS package in 32-bit windows and 64 bit windows.

4) The 32-bit support dtexec.exe will be present in” D:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn” and the 64-bit support dtexec.exe will be present in “D:\Program Files\Microsoft SQL Server\100\DTS\Binn”.

5) The folder name ends with (x86) contains the 32-bit support files

6) Then I defined a new Sql Server Job in Sql server 2008 management studio

7) In the job step creation I selected the cmdExec as operating system and typed the following command:

"D:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /File "C:\DTSPkg\DTSPkg1.dtsx "

Then I ran the SQL Job. The 32-bit driver made a successful transition to the 64-bit operating system.

Viewing installed 32-bit drivers in 64-bit platform:

As the Windows 2008 supports both 32-bit and 64-bit, when we click on Data Sources (ODBC) From Program Menu/Control Panel, we cannot see the installed 32-bit drivers as it will display only the 64-bit drivers.

clip_image002

The reason is that the exe runs from System32 Folder (64-bit drivers)

To view the 32-bit drivers we need to type the following the command prompt

Ø %WINDIR%\SysWow64\odbcad32.exe

clip_image004

In the above picture is highlighted, a MERANT 3.60 32 –BIT Progress SQL92 V91.1 C which is the required ODBC driver for connecting Progress Databases of SYTELINE ERP’s to SQL Server

Migration of Windows 32-bit mode .NET application to 64-bit platform:

After the installation of 32-bit drivers in 64-bit platform, the next problem was the migration of the .Net application which was developed in 32-bit mode to the new 64-bit machine.

When I start running my application to connect with the legacy database, I got the following informative error:

“error[ im014] [Microsoft][ODBC Driver Manager]The specified DSN contains an architecture mismatch between the Driver and Application”

The error clearly indicates the architecture difference between the LegaSync application and New 64-bit Server and the application needs to be run in X86 architecture (32-bit platform)

Solution:

Creating platform specific apps

Most of the language compilers (like C#) now offer a /platform switch. By using this switch, developers can create binaries targeted for a specific platform type or binaries that are platform agnostic. There are four types of binaries that are emitted

· any cpu – platform agnostic

· x86 – 32-bit platform specific

· x64 – x64 platform specific

By default the compilers (like C#) emit anycpu binaries (also called portable assemblies) which are platform agnostic. In case the users want to create binaries specific to a platform, they can use the appropriate switch and be done.

Cross Compilation

The above concept of /platform switch enables cross compilation of binaries. Cross compilation means compiling binaries to a specific platform type (different from the current platform). This is mostly used in terms of compiling and creating 64-bit assemblies from a 32-bit compiler and vice versa. One point to note here is that cross compilation usually refers to compiling to different target types from the compilers shipped with the 64-bit Redist (WoW and 64-bit). The reason for this is that, while trying to compile for a 64-bit platform from a pure 32-bit machine, the 32-bit Redist would not have the components that are 64-bit specific. In such cases the compilation might go through with warning but execution might lead to runtime exceptions. Also, one should note that while cross compiling, users should stick to the platform architecture type of the machine, viz. x64 or IA. Assemblies for IA and x64 are specific to the platform architecture and cross compilation across architectures is not advised.

How to create platform specific apps?

Steps:

1) Go to Project->Properties->Compile

2) Click On Advanced Compile Options button

3) Change the Target CPU to X86 /X64 – default Any CPU

4) Rebuild the application

clip_image006

As I wanted the application to run in 32-bit mode in Compatible with X86 architecture, I Chose X86 CPU Compile Options.

The application started working fine.