|
-
Jun 30th, 2005, 08:39 AM
#1
Thread Starter
Addicted Member
Runtime error 3705 & 3704 / msdn no help
I am getting two different runtime errors that I cannot figure out. I origionally didn't have the Rs.close in this code but I put it there hopeing to fix the error. But I have had no luck in trying to figure this out. I also tried the suggestions at MSDN, http://support.microsoft.com/defaul...kb;en-us;275927, but that hasn't worked either.
Any suggestions?? Many thanks.
visual basic code:'change query to select all buildings
'Rs.Close
strsql = "select bldg from bldgtype where type = 1 order by bldg"
Rs.Open strsql, Db
Run-time error: '3705': Operation is not allowed when the object is open.
visual basic code:'change query to select all buildings
Rs.Close
strsql = "select bldg from bldgtype where type = 1 order by bldg"
Rs.Open strsql, Db
Run-time error: '3704': Operation is not allowed when the object is closed.
-
Jun 30th, 2005, 08:42 AM
#2
PowerPoster
Re: Runtime error 3705 & 3704 / msdn no help
you could try to completely get rid of it...
rs.close
set rs = nothing
set rs = new adodb.recordset
strsql = "select bldg from bldgtype where type = 1 order by bldg"
Rs.Open strsql, Db
-
Jun 30th, 2005, 08:47 AM
#3
Thread Starter
Addicted Member
Re: Runtime error 3705 & 3704 / msdn no help
Thank you!!!
VB Code:
Set Rs = Nothing
Set Rs = New ADODB.Recordset
strsql = "select bldg from bldgtype where type = 1 order by bldg"
Rs.Open strsql, Db
Works perfectly!!!
-
Jun 30th, 2005, 08:57 AM
#4
PowerPoster
Re: Runtime error 3705 & 3704 / msdn no help
No problemo. Glad to help.
-
Jun 30th, 2005, 10:47 AM
#5
Re: Runtime error 3705 & 3704 / msdn no help
IMHO, it is better to "close" objects properly, rather than abruptly ending the instance by setting it to nothing. If an object has a Close method, call it.
Based on the information it looks like you are calling this procedure multiple times. Just check the state of the rs object and act accordingly.
VB Code:
If rs is Nothing then
Set rs = New ADODB.Recordset
End If
If rs.State = adStateOpen then
rs.Close
End If
strsql = "select bldg from bldgtype where type = 1 order by bldg"
Rs.Open strsql, Db
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|