ZuperDuper
Programmer
I have an application that is using Access database, and crystal reports. Within the application I need to be able to view crystal reports that are using the databse. then exit out of the crystal reports, and rerun/repopulate the access database with different set of data., then view crystal reports again.
The problem is that I get an error that tells me that the file(database) is being used by another proccess. I try to delete the file before I recreate it with the following code:
sResults is the path to the access database.
If File.Exists(sResults) Then
' Try
Kill(sResults)
' Catch e As Exception
' MsgBox(e.Message)
' End Try
End If
I have examined my code, and it looks like the error comes up only when I use crystal reports to access data. Which leads me to believe that once I close the report viewer, it is still using the access tables.
I tried to dispose the CRVIEWER9 object once I close the form on which it is located, that does not work, BTW I think that the object is automatically disposed once the form that its attached to is gone.
path is the location of the access data in this example where I am initializing crviewer object.
Public Sub ProcessReport(ByVal intDestination As Integer, ByVal path As String, ByVal text As String)
form3.InitializeLifetimeService()
form3 = New Form3
If intDestination = 0 Then
With form3.CRVIEWER9
.ReportSource = path
.RefreshReport()
.Show()
End With
form3.Text = text
form3.Show()
Else
With form3.CRVIEWER9
.Visible = False
.ReportSource = path
.PrintReport()
End With
End If
End Sub
What is the problem, and is tere a way to make sure what process exactly is using my access database?
You should never underestimate the predictability of stupidity.