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!

SQL Connection remains open after report is closed 1

Status
Not open for further replies.

jojo11

Programmer
Feb 2, 2003
189
US
I have a vb6 app that has several crystal reports in it. The CR's were developed with ver. 8.5 and added as a designer. It is displayed using the CRViewer control on a form. We open the connection with a Logonserver. After the user closed the form and we go into sql server with an sp_who, the connection remains open until they log completely off of the app.
Any ideas?

-------------------------------------------
When you have spent all day trying to work through a problem, it is best to take a step back, reevaluate the problem, then work on the next project and never let the old one show its ugly face again!!
 
Two options (maybe someone else can come up with some others):

1) Call the LogOffServer method after you send the report to the Viewer. It takes the same arguments as the LogOnServer method.

From the help files:
The LogOnServer Method logs on to an SQL server or ODBC data source. Once logged on using this method, you will remain logged on until you call the LogOffServer Method or until the Application Object is destroyed.

2) Use the SetLogOnInfo method instead. This is how I use it in one application that connects to a SQL Server via ODBC:
[tt]
Dim crxTables As CRAXDRT.DatabaseTables
Dim crxTable As CRAXDRT.DatabaseTable

Set crxTables = Report.Database.Tables
For Each crxTable In crxTables
With crxTable
.Location = .Name
.SetLogOnInfo DSN_NAME, DB_NAME, USER_ID, USER_PASS
End With
Next
[/tt]
-dave
 
1) Thanks for the advice. The first method doesn't do the trick. No errors debugging, it just does not close the connection, in fact opening and closing multiple connections leave a trail of several connections open until the app is closed.
2) We use stored_Procedures so I am not sure if we can use the second option.

-------------------------------------------
When you have spent all day trying to work through a problem, it is best to take a step back, reevaluate the problem, then work on the next project and never let the old one show its ugly face again!!
 
90% of my reports in that application use stored procs... it works without any problems.

The line [tt].Location = .Name[/tt] is there to get rid of the "junk" that Crystal saves in Location (e.g. <dbname>.<owner>.Proc(<procName>;1).

-dave
 
Thanks for the help...Solution 2 worked@!

-------------------------------------------
Ummm, we have a bit of a problem here....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top