I have a value of 100 from a textBox and I want to increment that value in the stock_out column but only till stock_out column is equal to stock_in column, if first row value is 40 than first row stock_out should be incremented by 10 from 100 than the remaining value from 100(90) should be incremented in the row below it and then row below it till needed (till 100 is 0). Items are ordered by Item_Name and Bill No asc.
C# code SQL Query
select * from stock_recieve where Item_Name like'" + comboBoxitem.Text + "' where Stock_out < Stock_in order by [Bill No] asc; update stock_recieve set Stock_out = Stock_out+" + qty + " where Stock_out < Stock_in;
Any help would be greatly appreciated.
P.S I know about the sql injection and I will change my sql queries to parameterized queries.