hi everyone,
i need ur help in the following code as i had tried this code many times but doesn't got the desired results. so plz help me out .
SqlCommand cmd1 = new SqlCommand("UPDATE entry SET stock = stock - '"+textBox22.Text+ "'Where name='" + textBox1.Text + "'", conn);
Loading
Krishna GaradPosted Jan 25, 2012, 2:34 AM
Create Procedure Sp_UpdateStock
(
@stockval int,
@name Varchar(50)
)
as
Begin
Declare @oldstock int
Set @oldstock=(Select Stock From Entry Where Name=@name)
Begin
Update Entry Set Stock=@oldstock-@stockval Where Name=@name
End
End
And call this procedure from your front end but make sure your old stock value not be null if it is null then set it default to 0.
Satyapriya NayakPosted Jan 25, 2012, 2:16 AM
Try this...
SqlCommand cmd1 = new SqlCommand("UPDATE entry SET stock ='" + textBox22.Text + "' Where name='" + textBox1.Text + "'", conn);
Thanks