如何解决此错误"过程或函数指定了太多参数"

时间:2014-09-06 18:15:01

标签: sql asp.net sql-server stored-procedures

两个程序都有同样的问题!

在gridview上按更新时显示此消息:

  

过程或函数指定了太多参数

第一个程序:

ALTER PROCEDURE ModifyonEmployee
(
   @original_id  int, @mobileNumber nvarchar(15), @Nationality nvarchar(20), @BirthPlace nvarchar(20), @BirthDate date, @Qualification nvarchar(8), 
   @Specialization nvarchar(30), @Identity_Type nvarchar(8), @Identity_source nvarchar(50), @Identity_Number nvarchar(30), 
@Mahram_Name nvarchar(30), @Mahram_relation nvarchar(30), @Mahram_Job nvarchar(30), @Mahram_mobile nvarchar(30), @Address nvarchar(60), 
@Home_phone nvarchar(30), @daily_salary int , @Job_title nvarchar(30), @email nvarchar(30), 
@Name nvarchar(50), @time nvarchar(50), @identityDate date, @identityEndDate date, 
@empid nvarchar(20) , @IBAN nvarchar(50), 
@cir1 nvarchar(300), @cir2 nvarchar(300), @cir3 nvarchar(300), @cir4 nvarchar(300), 
@joining date , 
@home_job_title nvarchar(30), 
@MaritalStatus nvarchar(50), 
@startDate date
)
AS
BEGIN TRANSACTION
UPDATE Employees SET Nationality = @Nationality, BirthPlace = @BirthPlace, BirthDate = @BirthDate, Qualification = @Qualification, 
Specialization = @Specialization, mobileNumber = @mobileNumber, Identity_Type = @Identity_Type, Identity_source = @Identity_source, 
Identity_Number = @Identity_Number, Mahram_Name = @Mahram_Name, Mahram_relation = @Mahram_relation, Mahram_Job = @Mahram_Job, 
Mahram_mobile = @Mahram_mobile, Address = @Address, Home_phone = @Home_phone, daily_salary = @daily_salary, job_Title = @Job_title, 
email = @email, [Name] = @Name, [time] = @time, identityDate = @identityDate, identityEndDate = @identityEndDate, empid=@empid, 
IBAN=@IBAN , cir1=@cir1 , cir2=@cir2 , cir3=@cir3 , cir4=@cir4, joining = @joining, home_job_title=@home_job_title, 
MaritalStatus=@MaritalStatus, startDate=@startDate WHERE  [id] = @original_id  

UPDATE Users 
SET [mobileNUmber] = @mobileNumber  
WHERE userid = @original_id

COMMIT

ASP代码:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConflictDetection="CompareAllValues" 
                    ConnectionString="<%$ ConnectionStrings:SchoolCon %>" 
                      OldValuesParameterFormatString="original_{0}" 
                    SelectCommand="SELECT[Employees].*  FROM [Employees]  WHERE ([empId] = @id)" 

                        UpdateCommand="ModifyonEmployee" UpdateCommandType="StoredProcedure">

   <SelectParameters>
       <asp:ControlParameter ControlID="idTxt" Name="id" PropertyName="Text" 
                            Type="String" />
   </SelectParameters>
   <UpdateParameters>
       <asp:Parameter Name="original_id" Type="String" />
       <asp:Parameter Name="mobileNumber" Type="String" />
       <asp:Parameter Name="Nationality" Type="String" />
       <asp:Parameter Name="BirthPlace" Type="String" />
       <asp:Parameter DbType="Date" Name="BirthDate" />
       <asp:Parameter Name="Qualification" Type="String" />
       <asp:Parameter Name="Specialization" Type="String" />
       <asp:Parameter Name="Identity_Type" Type="String" />
       <asp:Parameter Name="Identity_source" Type="String" />
       <asp:Parameter Name="Identity_Number" Type="String" />
       <asp:Parameter Name="Mahram_Name" Type="String" />
       <asp:Parameter Name="Mahram_relation" Type="String" />
       <asp:Parameter Name="Mahram_Job" Type="String" />
       <asp:Parameter Name="Mahram_mobile" Type="String" />
       <asp:Parameter Name="Address" Type="String" />
       <asp:Parameter Name="Home_phone" Type="String" />
       <asp:Parameter Name="daily_salary" Type="Int32" />
       <asp:Parameter Name="Job_title" Type="String" />
       <asp:Parameter Name="email" Type="String" />
       <asp:Parameter Name="Name" Type="String" />
       <asp:Parameter Name="time" Type="String"/>
       <asp:Parameter Name="identityDate" DbType="Date" />
       <asp:Parameter Name="identityEndDate" DbType="Date"/>
       <asp:Parameter Name="empid" Type="String" />
       <asp:Parameter Name="IBAN" Type="String" />
       <asp:Parameter Name="cir1" Type="String"  />
       <asp:Parameter Name="cir2"  Type="String"  />
       <asp:Parameter Name="cir3" Type="String"  />
       <asp:Parameter Name="cir4" Type="String"  />
       <asp:Parameter Name="joining" DbType="Date"/>
       <asp:Parameter Name="home_job_title"  Type="String"/>
       <asp:Parameter Name="MaritalStatus" Type="String" />
       <asp:Parameter Name="startDate" DbType="Date"  />
   </UpdateParameters>
</asp:SqlDataSource>

第二个程序:

ALTER PROCEDURE ModifyMobileNum
(
   @original_id    int,
   @mobileNumber nvarchar(15)
)
AS
   BEGIN TRANSACTION

   UPDATE [Employees] 
   SET [mobileNumber] = @mobileNumber 
   WHERE [id] = @original_id

   UPDATE Users 
   SET [mobileNUmber] = @mobileNumber  
   WHERE userid = @original_id

   COMMIT

ASP代码:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConflictDetection="CompareAllValues" 
                            ConnectionString="<%$ ConnectionStrings:SchoolCon %>" 
                            OldValuesParameterFormatString="original_{0}" 
      SelectCommand="SELECT employees.id, Employees.name,  UserId,users.mobileNumber  FROM [Employees], users where employees.id = users.UserId and employees.Identity_Number LIKE @empIde" UpdateCommand="ModifyMobileNum" 
      UpdateCommandType="StoredProcedure">
   <SelectParameters>
      <asp:ControlParameter ControlID="TextBox1" DefaultValue="%%" Name="empIde" 
                                    PropertyName="Text" />
   </SelectParameters>
   <UpdateParameters>
       <asp:Parameter Name="original_id" Type="String" />
       <asp:Parameter Name="mobileNumber" Type="String" />
   </UpdateParameters>
</asp:SqlDataSource>

非常感谢

0 个答案:

没有答案