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,324 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

Technology Partners: 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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 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