Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB - Database.logoffserver error

Status
Not open for further replies.

pheare

Programmer
Mar 12, 2004
2
CA
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.
 
Someone had an issue yesterday with connections staying open: Thread766-797273.

Try using the SetLogOnInfo method (as described in the aforementioned thread) instead of LogOnServer. It takes care of closing the connection automatically.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top