我有一个调用存储过程的ListView
create procedure GetTicketJob
@JobID int
as
select JobID, TicketNum, UnitID, TicketDate, ChargeToCu, RecievedToCu, DeliverToCu,
DeliveredToLSD, ChargedToLSD, RecievedFromLSD, P.ProductName,
ProductVolume, Subtotal, GST, Total, PreJobNotes, JobDesc
from Tickets T
full outer join Products P
on T.ProductID = P.ProductID
where JobID=@JobID
go
这是按预期工作的。我的问题是,当我尝试使用内置插入模板插入时。我调用了一个应插入同一个表的不同存储过程:
create proc InsertTicketJob
@JobID int,
@TicketNum int,
@UnitID nvarchar(5),
@TicketDate datetime,
@ChargeToCu int,
@RecievedToCu int,
@DelieverToCu int,
@DeliveredToLSD nvarchar(30),
@ChargedToLSD nvarchar(30),
@RecievedFromLSD nvarchar(30),
@ProductName nvarchar(50),
@ProductVolume int,
@Subtotal int,
@GST int,
@Total int,
@PreJobNotes nvarchar(300),
@JobDesc nvarchar(300)
as
insert into Tickets
values(@TicketNum, @JobID, @TicketDate, @ChargeToCu, @RecievedToCu, @DelieverToCu, @DeliveredToLSD, @ChargedToLSD,
@RecievedFromLSD, @ProductVolume, (select ProductID
from Products
where ProductName=@ProductName), @Subtotal, @GST, @Total, @PreJobNotes, @JobDesc, @UnitID)
go
当我尝试这样做时,我收到错误:
"Procedure or function InsertTicketJob has too many arguments specified."
根据我的理解,我不是要求许多参数。我在ListView和SQL
中指定了相同的数量任何帮助都会受到极大关注。
答案 0 :(得分:1)
IMHO,在Insert语句中..请在Insert中指定字段/列。这是为了确保您在正确的字段中插入了正确数量的数据。 这也可以避免您的错误。
示例:
Insert Into Table1 (Name, Address, ZipCode) Values (@Name, @Address, @Zipcode)