Re: Corrupt SQL CE database.
I might have solved this myself , just dont delete everything from a table and do inserts again or watch where you open your PDA Sqlconnection always close it at the right place.
Re: Corrupt SQL CE database.
the dlls must be in the applications installation directory or else in the windows directory
Re: Corrupt SQL CE database.
Im still getting random corrupt database messages.
What's the best practice to avoid corrupt databases , are they connection related or , should i be using DataAdapters instead of insertcommand or updatecommands.
Most of my code subs looks like this
Code:
Dim sqlConn As SqlCeConnection = New SqlCeConnection("Data source=.\My Documents\PDADATA3.sdf")
sqlConn.Open()
dim command as new insertcommand
'insercommand.parameters.add("")...
'...or updatecommand..
insertcommand.executenonquery
sqlconn.close
Ive got many subs looking like this , should i try setting the SQlconn as a private and open it in formload ?
Im always able to repair and compact the database.
But this will give my users another thing to worry about..
Re: Corrupt SQL CE database.
Hi,
personally, I open the database at the beginning, and close at the end, for performance reasons.
After mass inserts/deletes, it is always worth doing a compact
Pete
Re: Corrupt SQL CE database.
Hi ,
My program doesnt really have a beginning or an end , users can select "previous" or "next" while they go through the forms , or can i use Form.Activate or form.deactivate.
Im using Compact on the database now atleast once after an insert , and i hope my problems are now over , havent gotten a single corrupt database yet.
thx.
Re: Corrupt SQL CE database.
Hi,
again, I would open in your 'sub main' or at the start of your first form, and close when you exit the program, log off, compact etc.
I am sure you will get better performance as opening a connection is fairly heavy
Pete
Re: Corrupt SQL CE database.
Thx ,
I noticed a nice boost on the heavier forms.
Re: Corrupt SQL CE database.
Code:
Dim src As String
src = "\My Documents\PDADATA3.SDF"
Dim pw As String = ""
Dim dest As String = "\My Documents\PDADATA4.SDF"
' Initialize SqlCeEngine Object.
Dim engine As New SqlCeEngine("Data Source = " + src + ";password=" + pw)
Try
engine.Compact(("Data Source = " + dest))
engine.Dispose()
verhoog()
File.Delete(src)
File.Move(dest, src)
'MessageBox.Show("Compact Done...", "SQL CE 2.0 App", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button2)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
'Dispose of the SqlCeEngine object.
engine.Dispose()
End Try
This is working nicely to counter the errors.