这是我的Master table Recruiter,我在其中设置了两个主键(Recruiter_ID,Status)来将它们作为复合键... 我将此表绑定到gridview以在表上进行更新(即更新操作) 我不想通过更新命令实际更新表字段... 在执行更新记录之前,其状态字段值应为0或大于1但不是1 ... status = 1表示它是当前记录..
这是我更新记录的存储过程......它在sql server management studio中完美执行..
ALTER procedure [dbo].[Update_recruiter]
(
@Recruiter_ID int,
@CompanyName varchar(50),
@CompanyAddress varchar(50),
@Location int,
@ContactNumber varchar(50),
@Email varchar(50),
@CompanyWebsite varchar(50)
)
as
begin
declare @temp int
select @temp = max ([Status])
from New_Recruiter
where Recruiter_ID = @Recruiter_ID
update New_Recruiter
set [Status] = @temp +1
where Recruiter_ID = @Recruiter_ID and [Status] = 1
SET IDENTITY_INSERT New_Recruiter ON
insert into New_Recruiter
(
Recruiter_ID,
Company_Name ,
Company_Address ,
Location ,
Contact_Number ,
Email ,
CompanyWebsite,
[Status],
[DateTime]
)
values
(
@Recruiter_ID,
@CompanyName ,
@CompanyAddress ,
@Location ,
@ContactNumber ,
@Email ,
@CompanyWebsite ,
1,
getdate()
)
SET IDENTITY_INSERT New_Recruiter OFF;
end
但是当我将此过程附加到网格视图时......它给出了错误,即过程或函数Update_recruiter指定了太多参数。
这里是网格视图aspx代码
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="UpdateReSqlDataSource1" CssClass="grid" AllowSorting="True" DataKeyNames="Recruiter_ID">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Recruiter_ID" HeaderText="Recruiter_ID" InsertVisible="False" ReadOnly="True" SortExpression="Recruiter_ID" />
<asp:BoundField DataField="Company_Name" HeaderText="Company_Name" SortExpression="Company_Name" />
<asp:BoundField DataField="Company_Address" HeaderText="Company_Address" SortExpression="Company_Address" />
<asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
<asp:BoundField DataField="Contact_Number" HeaderText="Contact_Number" SortExpression="Contact_Number" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="CompanyWebsite" HeaderText="CompanyWebsite" SortExpression="CompanyWebsite" />
</Columns></asp:GridView>
<asp:SqlDataSource ID="UpdateReSqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RCConnectionString %>" SelectCommand="sp_Display_Recruiter" UpdateCommand="Update_recruiter" SelectCommandType="StoredProcedure" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="Recruiter_ID" Type="Int32" />
<asp:Parameter Name="CompanyName" Type="String" />
<asp:Parameter Name="CompanyAddress" Type="String" />
<asp:Parameter Name="Location" Type="Int32" />
<asp:Parameter Name="ContactNumber" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="CompanyWebsite" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>