Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Button
C#
Business_Logic.Employee objpo = new Business_Logic.Employee();
   objpo.Position_Number = TxtPositionNum.Text;
   objpo.Grade = TxtGrade.Text;
   objpo.StartDate = Txtstartda.Text;

   objpo.UpdatePosition(LblPositNum.Text);

Business Logic
C#
     public void UpdatePosition(string Position_Number)
       {

                    csDAL objdal = new csDAL();
           List<csparameterlisttype>objl = new List<csparameterlisttype>();
          
 objl.Add(new csParameterListType("@Position_Number", SqlDbType.VarChar, Position_Number));
           
objl.Add(new csParameterListType("@Grade", SqlDbType.VarChar, Grade));
           
objl.Add(new csParameterListType("@StartDate", SqlDbType.VarChar, StartDate));
                  
  objdal.executespreturnds("Update_Position", objl);
       }

SQL
SQL
Create procedure [dbo].[Update_Position]
(@Position_Number char(15),
@Grade varchar(5),
@StartDate varchar(1000)
)
as update PositionInformation set Position_Number=@Position_Number,Grade = @Grade,StartDate =@StartDate 
where Position_Number=@Position_Number
Posted
Updated 28-Jul-15 20:33pm
v4

You would need to use two parameters for te position number, the old one and the new one. COnsider the following:
SQL
Create procedure [dbo].[Update_Position]
(@Position_Number_old char(15),
@Position_Number_new char(15),
@Grade varchar(5),
@StartDate varchar(1000)
)
as 
update PositionInformation 
set Position_Number=@Position_Number_new,
    Grade = @Grade,
    StartDate =@StartDate 
where Position_Number=@Position_Number_old

But before jumping to that, in my opinion, you should really modify the parameter types and column types correspondingly. Never store dates or number in character types. Instead use proper types such as date, int, float .
 
Share this answer
 
By principle, a primary key should never change because the value does not matter. What matters is that the value is unique to each record and it is used as link between bases.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900