ADODB.Recordset: Operation is not allowed when the object is closed. (3704)
- From: Randy Snyder <aggie07@xxxxxxxxxxxxx>
- Date: Tue, 17 Jul 2007 15:55:50 -0500
I have very little experience with ADO. I wrote the script below. I am attempting to open a connection to a Microsoft SQL database, run a query and then echo out the data that is returned.
I am able to establish a connection with the database; however, I get a "ADODB.Recordset:Operation is not allowed when the object is closed." (Error Number 3704)
What I am missing? I appreciate any assistance you can provide.
-Randy
------------8<------------------
sqlText = "USE IMYahooDB " & _
"select * " & _
"from messages " & _
"where (sender_im ='sip:joe_user@xxxxxxxxx') or " &_
"(recipient_im = 'sip:joe_user@xxxxxxxxx') " & _
"order by message_date"
Set cn = CreateObject("ADODB.Connection")
cn.Open = "PROVIDER=sqloledb;" &_
"DATA SOURCE=DBServer01;" &_
"DATABASE=IMYahooDB;" &_
"Integrated Security=SSPI"
If cn.State = 1 Then
WScript.Echo "Connection is open."
Else
WScript.Echo "There is a problem with the connection."
WScript.Quit(1)
End If
'Set rs = CreateObject("ADODB.RecordSet")
Set rs = cn.Execute(sqlText)
rs.ActiveConnection = cn
rs.Open sqlText,cn
If rs.EOF Then
WScript.Echo "No records returned."
Else
Do While NOT rs.EOF
WScript.Echo rs("sender_name")
WScript.Echo rs("message_date")
rs.MoveNext
Loop
End If
cn.Close
rs.Close
Set cn = Nothing
Set rs = Nothing
WScript.Quit(0)
------------8<------------------
.
- Follow-Ups:
- Re: ADODB.Recordset: Operation is not allowed when the object is closed. (3704)
- From: Richard Mueller [MVP]
- Re: ADODB.Recordset: Operation is not allowed when the object is closed. (3704)
- Prev by Date: Re: !VB.NET/Access: OleDbException (Data type mismatch in criteria expression)
- Next by Date: Re: ADODB.Recordset: Operation is not allowed when the object is closed. (3704)
- Previous by thread: !VB.NET/Access: OleDbException (Data type mismatch in criteria expression)
- Next by thread: Re: ADODB.Recordset: Operation is not allowed when the object is closed. (3704)
- Index(es):
Relevant Pages
|
|