我已經創建瞭如下所示的存儲過程,我將如何從後面的c#代碼調用此函數來獲取結果並將結果存儲在數據集中。如何調用存儲過程與參數從c#代碼
USE [Test]
GO
/****** Object: StoredProcedure [dbo].[tesproc] Script Date: 09/01/2010 13:00:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[tesproc]
-- Add the parameters for the stored procedure here
@a float, @b float, @c float,@d int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select Id, Name1,ZipCode,StreetName,StreetNumber,State1,Lat,Lng, (6371 * ACOS(COS((@a/@b)) * COS( (Lat/@b) ) * COS((Lng/@b) - (@c/@b)) + SIN(@a/@b) * SIN( Lat/@b ))) as distance from business_details where (6371 * ACOS(COS((@a/@b)) * COS( (Lat/@b) ) * COS((Lng/@b) - (@c/@b)) + SIN(@a/@b) * SIN( Lat/@b )))<@d
END
如果我在SQL Server中執行此存儲過程的做工精細與此以下調用
exec dbo.tesproc 12.9216667 ,57.2958,77.591667,1
你見過http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx嗎?簡單的Google搜索「從ADO.net調用存儲過程」將爲您提供所有您需要的信息! – InSane 2010-09-01 08:40:16