|
-
Apr 20th, 2007, 06:07 AM
#1
Thread Starter
Member
Corrupt SQL CE database.
Hi ,
Im getting totally random Corrupt databases with SQL CE.
Are there any precautions i can take against this ?
Is there a way to tell what's causing the problem?
Im doing quite alot of unfriendly things to the database like deleting an entire table and inserting stuff again, but still everything should work , cause one time its giving me no errors at all , next time i use the query analyzer with a big(select statement) it gives error messages.
mzzzz , could it be that the query analyzer reports a message about it being corrupt while it is not , but still locks the .sdf file ?
Im also trying to use the Built in Compacter and repair utility but it keeps saying im missing the SqlCompact30.dll
(where do i put it , anyway)
thx for you help.
-
Apr 24th, 2007, 08:41 AM
#2
Thread Starter
Member
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.
-
Apr 24th, 2007, 09:25 AM
#3
Fanatic Member
Re: Corrupt SQL CE database.
the dlls must be in the applications installation directory or else in the windows directory
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Apr 30th, 2007, 05:37 AM
#4
Thread Starter
Member
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..
-
Apr 30th, 2007, 10:23 AM
#5
Frenzied Member
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
-
May 2nd, 2007, 02:06 AM
#6
Thread Starter
Member
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.
-
May 2nd, 2007, 04:18 AM
#7
Frenzied Member
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
-
May 2nd, 2007, 06:18 AM
#8
Thread Starter
Member
Re: Corrupt SQL CE database.
Thx ,
I noticed a nice boost on the heavier forms.
-
May 3rd, 2007, 09:47 AM
#9
Thread Starter
Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|