T-SQL and CLR types for return value do not match

Hi I am trying to create a CLR function to call a webservice, the CLR function return data type is double, whether I try to create this as a table valued funcion or a scalar to return a distance travelled value I am receiving the error below. I've tried changing data types around in the CLR side and the SQL side but keep receiving the same error message, any help would be appreciated,
Thank you,


[Microsoft.SqlServer.Server.SqlFunction(Name = "DistanceCalc")]
        public static Double DistanceCalc(Double SrcLat, Double SrcLong,
           Double DestLat, Double DestLong)
        {
            MileageWS ws = new MileageWS();
            ws.Url = "http://test.isp.ca/Distance.asmx";
            
            int intUom = 0;  // 0 = Mile, 1 = KM

            RouteType RouteMethod = RouteType.Practical;
            Requester RequestedFrom = Requester.LinkRoute;

            Double distance;

            distance = ws.GetDistanceInfoForLonLat(SrcLat, SrcLong, DestLat, DestLong, intUom, RouteMethod, RequestedFrom);
           
            return distance;
}

Open in new window


CREATE FUNCTION DistanceCalc
(		
	@SrcLat as float, @SrcLong as float, 
	@DestLat as float, @DestLong as float
)
RETURNS TABLE (Distance float)
External NAME CLRfunctions.RIFunctions.DistanceCalc
	
GO

Open in new window


Error received when try to Create function ...

Msg 6551, Level 16, State 2, Procedure pcMiler, Line 6
CREATE FUNCTION for "pcMiler" failed because T-SQL and CLR types for return value do not match.

Open in new window

Scarlett72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
Table of T-SQL data types, and CLR Equivalents
 SqlDouble  and Double in your instance
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scarlett72Author Commented:
I also had to create it as a scalar function, thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.