thegunner
thegunner

Reputation: 7163

sql Server error - 3709

Hi I keep getting the error:

Error (3709) - /mysite/Pages_Secure/mypage.asp ADODB.Recordset.

"The connection cannot be used to perform this operation. It is either closed or invalid in this context.."

strQuery = ""
strQuery = strQuery + "SET ROWCOUNT 0 "
strQuery = strQuery + "SELECT FIRSTNAME, LASTNAME, EMAIL, USER_TEAM_ID, USER_SERVICE_ID, USER_DIRECTORATE_ID "
strQuery = strQuery + "FROM Web_Users "
strQuery = strQuery + "WHERE USER_ID = '" + Cstr(lOwnerID) + "'"

CALL subOpenConnection("", "")

Set RS = Server.CreateObject("ADODB.RecordSet")

RS.Open strQuery, objDBConnection

Error happens here after the open....

SUB subOpenConnection( strErrorPage, strErrorQueryArguments )

    Set objDBConnection = Server.CreateObject("ADODB.Connection")

    objDBConnection.ConnectionTimeout = Application("ConnectionTimeout")
    objDBConnection.CommandTimeout = Application("CommandTimeout")
    objDBConnection.CursorLocation = Application("CursorLocation")
    objDBConnection.Open Application("ConnectionString") 

END SUB

Any ideas?

Upvotes: 0

Views: 1699

Answers (2)

thegunner
thegunner

Reputation: 7163

ok managed to get this working...can't quite remember how - but was something i had missed! D'oh!

Upvotes: 0

user174624
user174624

Reputation:

I think it's because you're using SUB rather than FUNCTION. The sub won't return the connection object (which is why you get an error that it's closed), whereas a function can return the connection object. Does this sub work anywhere else? Or is this the only time it's used?

Upvotes: 1

Related Questions