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
1,323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 250 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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