下面粘贴的是用SQL Server 2005编写的存储过程。我的目的是通过使用向导控件从我的ASP.NEt Web应用程序调用此sproc。我是SQL Server的新手,尤其是存储过程。我不确定为什么我的参数不能用于Web应用程序,并且在SSMS树视图中不可见作为我的sproc名称下的参数。你能帮我纠正下面的sproc,以便参数被正确实例化并可以在我的web应用程序中使用吗?
谢谢, SID
存储过程语法:
USE [Diel_inventory]
GO
/****** Object: StoredProcedure [dbo].[AddQuote] Script Date: 05/09/2010 00:31:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[AddQuote] as
Declare @CustID int,
@CompanyName nvarchar(50),
@Address nvarchar(50),
@City nvarchar(50),
@State nvarchar(2),
@ZipCode nvarchar(5),
@Phone nvarchar(12),
@FAX nvarchar(12),
@Email nvarchar(50),
@ContactName nvarchar(50),
@QuoteID int,
@QuoteDate datetime,
@NeedbyDate datetime,
@QuoteAmt decimal,
@ID int,
@QuoteDetailPartID int,
@PartNumber float,
@Quantity int
begin
Insert into dbo.Customers
(CompanyName, Address, City, State, ZipCode, OfficePhone, OfficeFAX, Email, PrimaryContactName)
Values (@CompanyName, @Address, @City, @State, @ZipCode, @Phone, @FAX, @Email, @ContactName)
set @CustID = scope_identity()
Insert into dbo.Quotes
(fkCustomerID,NeedbyDate,QuoteAmt)
Values(@CustID,@NeedbyDate,@QuoteAmt)
set @QuoteID = scope_identity()
Insert into dbo.QuoteDetail
(ID) values(@ID)
set @ID=scope_identity()
Insert into dbo.QuoteDetailParts
(QuoteDetailPartID, QuoteDetailID, PartNumber, Quantity)
values (@ID, @QuoteDetailPartID, @PartNumber, @Quantity)
END
答案 0 :(得分:2)
您的语法略有不正确(请参阅注释):
USE [Diel_inventory]
GO
/****** Object: StoredProcedure [dbo].[AddQuote] Script Date: 05/09/2010 00:31:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[AddQuote]
--// notice I just start defining parameters... no DECLARE, and no AS
@CustID int,
@CompanyName nvarchar(50),
@Address nvarchar(50),
@City nvarchar(50),
@State nvarchar(2),
@ZipCode nvarchar(5),
--//other parameters...
as
begin
-- body of procedure
end