multiplatform (pocketPC & desktopPC) (Daniel !!)



i solved some problem using compiler directives
#If PocketPC Then ....
Now i'm able to run the same code (but different compiled version) both
in PPC and Win32.

But, before this i normally use (in a module) specific SQLCE objects
without any problems...
It seems that classes objects are "different" from code in modules.
Example a simple class wrapper need to be compiled differently:
Public Class NxDataCache
Private O As Object


Public Sub New()
If Parametri.Palmare Then
O = DirectCast(O, NxDataCacheCE)
O = New NxDataCacheCE

Else
O = DirectCast(O, NxDataCacheDesktop)
O = New NxDataCacheDesktop
End If
End Sub


Public Sub PreparaDati(ByVal SQL1 As String, ByVal DataWindow1 As
Integer, ByVal DataTableName1 As String)

If Parametri.Palmare Then
#If PocketPC Then
DirectCast(O,
NxDataCacheCE).PrepareData(Parametri.Cn_SQLCE, SQL1, DataWindow1,
DataTableName1)
#End If
Else
DirectCast(O,
NxDataCacheDesktop).PrepareData(Parametri.Cn_SQL, SQL1, DataWindow1,
DataTableName1)
End If
End Sub
Public Sub FillDS(ByVal StartFrom As Integer, ByVal Size As
Integer)
If Parametri.Palmare Then
#If PocketPC Then
DirectCast(O, NxDataCacheCE).FillDS(StartFrom, Size)
#End If
Else
DirectCast(O, NxDataCacheDesktop).FillDS(StartFrom, Size)
End If
End Sub
ReadOnly Property SQLData() As System.Data.DataTable
Get
If Parametri.Palmare Then
#If PocketPC Then
Return DirectCast(O, NxDataCacheCE).SQLData
#Else
Return Nothing
#End If
Else
Return DirectCast(O, NxDataCacheDesktop).SQLData
End If
End Get
End Property
Protected Overrides Sub Finalize()
O = Nothing
MyBase.Finalize()
End Sub
End Class

but code in a module doesn't:

Private Sub RunSQL_CE(ByVal SQLString As String, Optional ByRef Errout
As String = "")
Dim C As New SqlServerCe.SqlCeCommand
C.CommandText = SQLString
C.Connection = Parametri.Cn_SQLCE
Try
C.ExecuteNonQuery()
Catch e As SqlServerCe.SqlCeException

Errout = SQLErrorCE(e)
End Try

C.Dispose()
End Sub
Private Sub RunSQL_Desktop(ByVal SQLString As String, Optional
ByRef Errout As String = "")
Dim C As New SqlClient.SqlCommand
C.CommandText = SQLString
C.Connection = Parametri.Cn_SQL
Errout = ""
Try
C.ExecuteNonQuery()
Catch e As SqlClient.SqlException

Errout = SQLErrorDesktop(e)
End Try

End Sub

Public Sub RunSQL(ByVal SQLString As String, Optional ByRef Errout
As String = "")

Errout = ""
If Parametri.Palmare Then
RunSQL_CE(SQLString, Errout)
Else
RunSQL_Desktop(SQLString, Errout)
End If
End Sub

Why this different behviour ?

thanks

.



Relevant Pages

  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... On the practical side of things, if you are using conditional compilation, ... Public Sub New ... Public Sub PreparaDati(ByVal SQL1 As String, ... Private Sub RunSQL_CE(ByVal SQLString As String, Optional ByRef Errout ...
    (microsoft.public.dotnet.framework.compactframework)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)
  • Re: FTP CD command
    ... My code connects to a ftp site and the enumerates all content on that place ... Public Property UriAs String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FTP CD command
    ... Private _Uri As String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ... Public Sub UploadAsynch(ByVal fileName As String, ByVal uploadUrl As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FTP CD command
    ... i remember to have seen a socket level FTP ... Private _Uri As String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ...
    (microsoft.public.dotnet.languages.vb)