Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operation is not allowed when the object is closed. 1

Status
Not open for further replies.

SWTpaul

Technical User
Nov 11, 2003
27
US
I get the following error: Operation is not allowed when the object is closed.

It points the the line that reads: While Not Rs.EOF

Sort of baffled, I don't know why the recorset would be closed?!

Code:
  Dim sZipCode, sMiles
  
  sZipCode	= "91403"
  sMiles	= 5

  Set MyConn = Server.CreateObject("ADODB.Connection")
  MyConn.Open "DSN=WEBSITE;UID=XXXX;PW=XXXX"
  sSQL = "Declare @HighLatitude float "&_
  	   "Declare @LowLatitude float "&_
		 "Declare @HighLongitude float "&_
		 "Declare @LowLongitude float "&_
		 "Declare @StartLatitude float "&_
		 "Declare @StartLongitude float "&_
		 "Declare @LatitudeRange float "&_
		 "Declare @LongitudeRange float "&_
		 
		 "SELECT @StartLatitude = Latitude, @StartLongitude = Longitude "&_
		 "FROM zipcd "&_
		 "WHERE zip = '"&sZipCode&"' "&_
		 "Set @LongitudeRange = '"&sMiles&"' / (((Cos(@StartLatitude * pi() / 180) * 6076.0) / 5280.0) * 60) "&_
		 "Set @LatitudeRange = '"&sMiles&"' / 69.045454545454545454545454545455 "&_
		 "Set @LowLatitude = @StartLatitude - @LatitudeRange "&_
		 "Set @HighLatitude = @StartLatitude + @LatitudeRange "&_
		 "Set @LowLongitude = @StartLongitude - @LongitudeRange "&_
		 "Set @HighLongitude = @StartLongitude + @LongitudeRange "&_
		 
		 "SELECT cmcsnm, cmcad1, cmcad2, cmcity, cmstat, cmzip4 "&_
		 "FROM cusms "&_
		 "WHERE cmzip4 IN(SELECT zip FROM zipcd WHERE (Latitude <= @HighLatitude AND Latitude >= @LowLatitude)  AND (Longitude <= @HighLongitude AND Longitude >= @LowLongitude)) "&_
		  "  AND cmslly > 3000"

  Set Rs = MyConn.Execute(sSQL)
  
  While Not Rs.EOF
    Response.Write(Rs("cmcsnm"))
    Rs.Movenext
  Wend
 
Change...
[tt] sSQL = "Declare @HighLatitude float "&_
"Declare @LowLatitude float "&_
"Declare @HighLongitude float "&_
[/tt]

To...

[tt]
sSQL = "[!]SET NOCOUNT ON[/!] " & _
"Declare @HighLatitude float "&_
"Declare @LowLatitude float "&_
"Declare @HighLongitude float "&_
[/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You may find this thread interesting. thread183-1197121

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Excellent... thank you... that was the next step.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top