Question : Datareader.Read() not returning any results

Hello,

I am trying to use a data reader to view the results of the following stored proc but it I don't seem to be getting any results.

I have attached the code here.

If I just use the second select statement it works fine .. but If I use the part where I select the longitude and latitude and stored in variables and then execute it,  thats when I get no results...

Hoping for some help.

Thanks,
Ashwin
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
ALTER PROCEDURE [dbo].[Trucks_byZipCodeAndRadius_Get] 
	
	 @Zipcode varchar(10),
	 @Radius  int
	
AS
BEGIN

		DECLARE @latitude  numeric(9,6), @longitude numeric(9,6)			

		SELECT  @latitude  = latitude,
	   				@longitude = longitude
	   				
		FROM    dbo.Zipcode
		WHERE   zipcode = @Zipcode 


  		
		SELECT TR.[TruckStartPointCity],
					 TR.[TruckEndPointCity],
					 TR.[TruckStartPointState],
					 TR.[TruckEndPointState],
					 TR.[TruckStartPointZip],
					 TR.[TruckEndPointZip],
					 TR.[TruckStartPointDate],
					 TR.[TruckEndPointDate],
					 T.*
		       
			FROM [dbo].[Truck] T INNER JOIN dbo.Truck_Route TR	ON T.TruckRouteId = TR.TruckRouteId	
				
			WHERE T.TruckRouteId 
			IN (
							SELECT TruckRouteId FROM dbo.Truck_Route 
							WHERE TruckStartPointZip IN
							(
								SELECT  CAST( zipcode AS INT)  FROM dbo.Zipcode
								WHERE (SQRT(POWER(((latitude - @latitude) *69.1),2) + 
								POWER(((longitude - @longitude)*53),2)) <= @Radius) 							
							)
		
					)
	
		
END

Answer : Datareader.Read() not returning any results

But make sure you test out the following derived table first with some know values:
1:
2:
3:
4:
5:
6:
SELECT	z.zipcode
FROM	dbo.Zipcode z1
	CROSS JOIN z2
WHERE	z1.zipcode = @Zipcode 
	AND SQRT(POWER(((z2.latitude - z1.latitude) * 69.1), 2) + 
	POWER(((z2.longitude - z1.longitude) * 53), 2)) <= @Radius
Random Solutions  
 
programming4us programming4us