18-08-19, 02:52 AM
(17-08-19, 06:55 PM)asemshahen5 كتب : بص يامعلم :اخى انا استعملت هذا الكود ويعمل بشكل صحيح ولكن بعد استعاده النسخه لا يقبل اى عمل على البرنامج ويخرج خطأ بانه لا يجد قاعده البيانات فى المسار وياخذ المسار الذى وضعت فيه النسخه الاحتياطيه وبعد ان اغبق البرنامج وافتحه مره اخرى يعود البرنامج الى طبيعته
PHP كود :
Dim SaveAccess As New SaveFileDialog With {.Filter = "Microsost Access 2007-2016|*.Accdb|All File|*.*", .ShowHelp = True}
If SaveAccess.ShowDialog = DialogResult.OK Then
''
TextBox1.Text = SaveAccess.FileName
'و الباقي من عندك من الكود الي تحت ده مش شيفه بسبب رسالة الخطأ'
End If
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim scrpath, destpath, compdestpath As String
Dim OFD As New OpenFileDialog
destpath = Application.StartupPath & " "
compdestpath = Path.Combine(destpath, "SADANY.accdb")
OFD.Filter = "Microsost Access 2007|*.Accdb"
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
scrpath = OFD.FileName
End If
If My.Computer.FileSystem.FileExists(compdestpath) = True Then
If MessageBox.Show(" هل تريد فعلا الاستعاده ", "تنبيه", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
Exit Sub
Else
My.Computer.FileSystem.DeleteFile(compdestpath)
My.Computer.FileSystem.CopyFile(OFD.FileName, compdestpath)
con.Open()
MsgBox("تم ستعاده النسخه بنجاح")
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
