LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Recordset or Object is closed HELP PLEASE!

Guys,
I am getting this stubborn error anytime I try to do
anything with my recordset: '3704' Operation is not
allowed when the object is closed.

I don't understand why this recordset is closed no matter
how I write the code for the recordset. I've tried
the 'open method', the 'connection object' method, and
now the 'command object' method (if the recordset is the
object the error is referencing).

I have added SET NOCOUNT ON, and SET ANSI_WARNINGS OFF to
the SQL that is passed under the variable strSQL1. But
it doesn't help. PLEASE HELP ME CRACK THIS ONE!!!!

Here is my code: (there is some debugging code near the
bottom):

'Create the connection string and the Recordset
Set adoCn = New ADODB.Connection
With adoCn
.ConnectionString = "Provider=SQLOLEDB;Integrated
Security=SSPI;Trusted_Connection=yes;Persist Security
Info=False;Server=SQLSERVER;Database=m2mdata01;Uid =sa;
Pwd=;"
.CursorLocation = adUseServer
.Open
End With

Set adoCm = New ADODB.Command
With adoCm
Set .ActiveConnection = adoCn
.CommandType = adCmdText
.CommandText = strSQL1
.Execute
End With

Set adoRs = New ADODB.Recordset
With adoRs
Set .ActiveConnection = adoCn
.LockType = adLockReadOnly
.CursorLocation = adUseServer
.CursorType = adOpenStatic
.Open adoCm '"SET NOCOUNT ON SET ANSI_WARNINGS OFF"
End With


'Attemps to debug below.
MsgBox "Connection state is " & adoCn.State

MsgBox "Recordset state is " & adoRs.State

adoRs.NextRecordset

MsgBox adoRs.State

adoRs.NextRecordset

MsgBox adoRs.State

Do While adoRs.State < adStateOpen
Set adoRs = adoRs.NextRecordset
lTryCount = lTryCount + 1
If lTryCount 100 Then
Exit Do
End If
Loop
MsgBox lTryCount

If adoRs.BOF And adoRs.EOF Then
MsgBox "No records in this recordset!"
End If

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset Problem - object is closed DBAL Excel Programming 0 June 4th 04 11:55 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Operation Is Not Allowed When The Object Is Closed Mike Carlson Excel Programming 4 October 29th 03 02:18 AM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"