hi ...
i want sum field (Sum) and field (Add value) ... then save in
Sum from next Row :
http://s5.picofile.com/file/8166315884/Untitled.png
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jitendra KumarPosted Jan 28, 2015, 12:17 AM
Please check this code. may this help you. if any problem plz reply.
// For create a table
CREATE TABLE [tbl_DemoCsharp](
[Id] [int] IDENTITY(1,1) NOT NULL,
[SumV] [int] NOT NULL,
[AddValue] [int] NULL,
CONSTRAINT [PK_tbl_DemoCsharp] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
and
this is a query
//i think Addvalue is a value that provide by you.
Update tbl_DemoCsharp
Set Addvalue=200
where id= (Select top 1 id from tbl_DemoCsharp Order by id Desc)
Insert into tbl_DemoCsharp(sumv)
Select top 1 Sumv + 200 as Sumval from tbl_DemoCsharp Order by id Desc
Select * from tbl_DemoCsharp
ghasem dehPosted Jan 27, 2015, 11:29 PM
ghasem dehPosted Jan 27, 2015, 10:18 AM
yes !
Jitendra KumarPosted Jan 26, 2015, 6:28 AM
what you want?
i means add column values and insert into new row in the table?
Akhil GargPosted Jan 26, 2015, 4:13 AM
for(int i=0;i {
if(i>0)
{
dataTableName[i]["Sum"]=Convert.ToInt32(dataTableName[i-1]["Sum"].ToString())+Convert.ToInt32(dataTableName[i-1]["Addvalue"].ToString());
}
}
try this