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,317 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 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now