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/default...b;en-us;275927, but that hasn't worked either.
Any suggestions?? Many thanks.
VB 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.
VB 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.
Re: Runtime error 3705 & 3704 / msdn no help
if you are going to make multiple calls to the db with a similiar query, have you tried to put this code in a function taking in the building type as a parameter, declare the rs locally to the function and pass back the recordset?
For instance:
Private Function GetBuildings(byVal bType as integer) as ADODB.Recordset
dim rs as new ADODB.RecordSet
rs.open "select bldg from bldgtype where type =" & bType & " order by bldg",db
return rs
End Function
You could also look into using a SqlDataAdapter instead of a recordset.