multiplatform (pocketPC & desktopPC) (Daniel !!)
- From: "merco" <d.mercanti@xxxxxxxxx>
- Date: 22 Mar 2006 06:49:57 -0800
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
.
- Follow-Ups:
- Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- From: Daniel Moth
- Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Prev by Date: Re: paging dataset sql CE
- Next by Date: Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Previous by thread: Connection refused error - 10061
- Next by thread: Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Index(es):
Relevant Pages
|