Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-15
4
Medium Priority
?
1,326 Views
Last Modified: 2008-02-01
ERROR "The connection cannot be used to perform this operation. It is either closed or invalid in this context.".  

==================CODE====================================

            rs = New ADODB.Recordset
            rs.CursorLocation = rs.CursorLocation.adUseClient
            rs.CursorType = rs.CursorType.adOpenForwardOnly
            If intMaxRecords > 0 Then
                rs.MaxRecords = intMaxRecords
            End If
            rs.StayInSync = False
            rs.Open(strSQL, vConn.mDBConn, ADODB.CursorTypeEnum.adOpenStatic, rs.LockType.adLockOptimistic)

===============================================================================


The VS.Net is giving me error at the last line.  I have open the connection using ADODB interface.

I do not know what is happening.  Please help
0
Comment
Question by:tgatif
4 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 1000 total points
ID: 20296327
make sure vConn.mDBConn has been defined correctly and is not busy with some other result set before this point.  try vConn.mDBConn.Open before the block you pasted
0
 
LVL 5

Expert Comment

by:pavaneeshkumar
ID: 20296627
Check the Stat property before opening reord set
Record set oopening will work only if Stat is eqa;s to ConnectionState.Open

0
 
LVL 4

Expert Comment

by:JunnickYso
ID: 20296851
One of the factor of this problem is a concurrent connection attempt. Either a current connection is still open. Im not quite familiar with RecordSets but the code stated might be under LOOP block the error will occur. Anyway check also ur strSQL variable, and nothing wrong with double check it.

Good Luck
0
 
LVL 8

Expert Comment

by:Autoeforms
ID: 20297735
how long are you keeping your connection open.
is your app off doing something else.
depending on your back end it may have terminated the connection because it was idle to long.
g
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question