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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Connection

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have memory leakage problem in my MTS. I am using
VB6.0/SQL2k/COM+
This is the snippet of code I am using in one of the
methods in my dll.
I wanted to open and close(release) the connection as
soon as it is done.
But I am getting the error message 'Operation is not
allowed when the object is open.'
in line numbers 10,20,30. I thing there should be a
better way to code.

Any help is highly appreciated.

Thank's alot.
Ami.

Set cnUser = CreateObject("ADODB.Connection")
Set rsUser = CreateObject("ADODB.Recordset")
cnUser.Open "File Name=" & App.Path & mcstrUDLAdminFileName

strSQL = "{call sp1("
strSQL = strSQL & "'" & a & "'"
strSQL = strSQL & ")}"
rsUser.Open strSQL, cnUser
If Not rsUser.EOF Then
intID = rsUser!Id
End If
rsUser.Close

strSQL = "{call sp2("
strSQL = strSQL & b & ""
strSQL = strSQL & ")}"
rsUser.Open strSQL, cnUser
rsUser.Close

strSQL = "{call sp3("
strSQL = strSQL & c & ""
strSQL = strSQL & ")}"
rsUser.Open strSQL, cnUser
10 rsUser.Close

strSQL = "{call sp4("
strSQL = strSQL & d & ""
strSQL = strSQL & ")}"
rsUser.Open strSQL, cnUser
20 rsUser.Close


strSQL = "{call sp5("
strSQL = strSQL & e & ""
strSQL = strSQL & ")}"
rsUser.Open strSQL, cnUser
30 rsUser.close


cnUser.Close
 
I also work with vb6/sql2k, but not com+.

I've had a similar problem though. I found out that if I gave it some time in between I solved it. I just put some DoEvents in. I also noticed that just one didn't work, but 3 in a row seemed to be what was needed...:eek:))..

You can always try it.

/Suss
 
Do you mean
rsUser.Open strSQL, cnUser
DoEvents
DoEvents
DoEvents
10 rsUser.Close

like this for 20 and 30.

Thank you.
 
Yes, that's how I meant. Hope it helped you..:eek:))

/Suss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top