Backup ERROR - with CODE - Pls Guide

Backup ERROR - with CODE - Pls Guide

Post by A_PK » Wed, 30 Mar 2005 12:00:48

below is the code for my backup.......pls help me ..
i have error message saying that i can not compact my
databased......SqlCEexception error
Dim f As IO.File
Dim eng As New SqlCeEngine

Const DATABASE_CONN = "Data Source = \My Documents\DBsource.sdf"
Const DATABASE_COMPACTED = "Data Source = \My Documents\Compact.sdf"

eng.LocalConnectionString = DATABASE_CONN
If f.Exists("\My Documents\Compact.sdf") Then f.Delete("\My

'rename the compacted file to textbox2.text - my textbox2.text
would be like "\My Document\Personal\DBBackup"
'DBBackup.sdf is the file I get the textbox2.text +
.sdf = "\My Document\Personal\DBBackup.sdf"

If f.Exists(TextBox2.Text & ".sdf") Then
f.Delete(TextBox2.Text & ".sdf")
f.Copy("\My Documents\Compact.sdf", TextBox2.Text & ".sdf")
f.Delete("\My Documents\Compact.sdf")
End If

Catch ex As SqlCeException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Compact Error")
Catch ioEX As IO.IOException
MsgBox(ioEX.Message, MsgBoxStyle.Exclamation, "I/O Error")

End Try
f = Nothing
eng = Nothing