G
Guest
After noticing that I was losing data after a soft reset, the kind people of this newsgroup informed me that I need to flush the database to permanantly commit any data. Has anybody come up with a proven way to do this without causing the application to crash? I am currently using the following VB.NET code which actually does the trick except that it causes the application to crash frequently
'*****************************
Imports System.Runtime.InteropService
Public Class FlushD
<DllImport("coredll.dll")>
Private Shared Function CeMountDBVol(ByVal pGUID As Byte(), ByVal lpszVol As String, ByVal dwFlags As Integer) As Intege
End Functio
<DllImport("coredll.dll")>
Private Shared Function CeFlushDBVol(ByVal pGUID As Byte()) As Intege
End Functio
<DllImport("coredll.dll")>
Private Shared Function CeUnmountDBVol(ByVal pGUID As Byte()) As Intege
End Functio
Public Shared Sub Commit(ByVal DBPath As String
Dim guid() As Byte = New Byte(8) {
CeMountDBVol(guid, DBPath, 3
CeFlushDBVol(guid
CeUnmountDBVol(guid
End Su
End Clas
'*********************************************
I call this routine everytime I enter a record on a form. It does what I want it to do in that it saves the most recent record if I soft reset the device. However, like a lot of people have experienced, the application becomes very unstable and will crash after entering 10 or so records. This obviously has to have been an issue with a ton of applications out there so there has to be someone who has figured this out! If anybody could post some code (VB.NET) and or any other suggestions so that I can avoid data loss on a soft reset it would be greatly appreciated
Thanks
Mike
'*****************************
Imports System.Runtime.InteropService
Public Class FlushD
<DllImport("coredll.dll")>
Private Shared Function CeMountDBVol(ByVal pGUID As Byte(), ByVal lpszVol As String, ByVal dwFlags As Integer) As Intege
End Functio
<DllImport("coredll.dll")>
Private Shared Function CeFlushDBVol(ByVal pGUID As Byte()) As Intege
End Functio
<DllImport("coredll.dll")>
Private Shared Function CeUnmountDBVol(ByVal pGUID As Byte()) As Intege
End Functio
Public Shared Sub Commit(ByVal DBPath As String
Dim guid() As Byte = New Byte(8) {
CeMountDBVol(guid, DBPath, 3
CeFlushDBVol(guid
CeUnmountDBVol(guid
End Su
End Clas
'*********************************************
I call this routine everytime I enter a record on a form. It does what I want it to do in that it saves the most recent record if I soft reset the device. However, like a lot of people have experienced, the application becomes very unstable and will crash after entering 10 or so records. This obviously has to have been an issue with a ton of applications out there so there has to be someone who has figured this out! If anybody could post some code (VB.NET) and or any other suggestions so that I can avoid data loss on a soft reset it would be greatly appreciated
Thanks
Mike