Hey all,
I am using the following to establish a connection to our sql server 2000 database and run a crystal report dsr:
-----------------------------------------
Private Sub Form_Load()
On Error GoTo ExitHandler
Dim lngErrNumber As Long
Dim strErrSrc As String
Dim strErrDesc As String
Dim strFunctionName As String
strFunctionName = Me.Name & ".Form_Load"
Screen.MousePointer = vbHourglass
Call Report.Database.LogOnServer ("p2sodbc.dll", "dbserver", "db", "user", "pass")
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
ExitHandler:
If Err.Number <> 0 Then
lngErrNumber = Err.Number
strErrSrc = Err.Source
strErrDesc = Err.Description
End If
'Cleanup any local objects
If lngErrNumber <> 0 Then
cmnDisplayError strFunctionName, strErrDesc, lngErrNumber,
strErrSrc
End If
End Sub
--------------------------------------------
The report runs fine. But when I try closing the database connection on the form_unload, using:
-----------------------
Report.Database.LogOffServer "p2sodbc.dll", "dbserver", "db", "user", "pass"
------------------------
I get an runtime error stating "Unable to log off. This server is still in use by some reports."
Without the LogOffServer the from closes, but my database connection does not terminate.
I am new to vb and would appreciate any suggestions.
Thanks.
Darren.
I am using the following to establish a connection to our sql server 2000 database and run a crystal report dsr:
-----------------------------------------
Private Sub Form_Load()
On Error GoTo ExitHandler
Dim lngErrNumber As Long
Dim strErrSrc As String
Dim strErrDesc As String
Dim strFunctionName As String
strFunctionName = Me.Name & ".Form_Load"
Screen.MousePointer = vbHourglass
Call Report.Database.LogOnServer ("p2sodbc.dll", "dbserver", "db", "user", "pass")
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
ExitHandler:
If Err.Number <> 0 Then
lngErrNumber = Err.Number
strErrSrc = Err.Source
strErrDesc = Err.Description
End If
'Cleanup any local objects
If lngErrNumber <> 0 Then
cmnDisplayError strFunctionName, strErrDesc, lngErrNumber,
strErrSrc
End If
End Sub
--------------------------------------------
The report runs fine. But when I try closing the database connection on the form_unload, using:
-----------------------
Report.Database.LogOffServer "p2sodbc.dll", "dbserver", "db", "user", "pass"
------------------------
I get an runtime error stating "Unable to log off. This server is still in use by some reports."
Without the LogOffServer the from closes, but my database connection does not terminate.
I am new to vb and would appreciate any suggestions.
Thanks.
Darren.