Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- From: "Daniel Moth" <dmoth74@xxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 15:19:26 -0000
First, do not single people out in the subject line. Besides showing bad
form, you are missing the help of many others... anyway...
You are showing code but not all of it. Something I can compile here and
look at would be nice. Are you in a debug or release configuration? Change
between them to see if you get different results as that would give us a
clue. Have you got option strict on? Turn it on at the project level and
deal with compilation errors before proceeding further.
On the practical side of things, if you are using conditional compilation,
not only you get the full power to be very specific about the code that runs
on each platform, but you should use it. So in your module, and anywhere
else, if the code doesn't apply for the platform then simply leave it out
(with conditional compilation). There is no point doing the runtime check.
You are currently doing both a runtime check and a compile time check... it
is a waste of code...
On the academic side of things, you are asking why the runtime checking
seems to work for you in the module but didn't in the class, right? Well,
put the same code in both and then we'll see if the behaviour is indeed
different. At the moment, the actual code in the two places is not
identical.
If you need more advice, send me the project and I'd be glad to look at it.
Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"merco" <d.mercanti@xxxxxxxxx> wrote in message
news:1143038997.862709.111230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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:
- References:
- multiplatform (pocketPC & desktopPC) (Daniel !!)
- From: merco
- multiplatform (pocketPC & desktopPC) (Daniel !!)
- Prev by Date: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Next by Date: Notify.SetUserNotification Error
- Previous by thread: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Next by thread: Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
- Index(es):
Relevant Pages
|
Loading