How to retrieve data from sqlserver
how to retrieve data from sqlserver . i store 5000 (its amount) i need to deduct the amount (if i give 5000-2000(textbox i give )3000 remaining should be shown in another textbox in asp.net using c#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


MuthuMari MRank #5,738 · 288 reputationPosted Apr 30, 2012, 2:13 AM EDT
use the below code
int a=Convert.ToInt32(Textbox1.Text);
int b=Convert.ToInt32(Textbox2.Text);
int c=a-b;
TextBox3.Text=Convert.ToString(c);
thanks.
If this post is useful then mark it as "Accepted Answer"
selvi subramanianRank #2,007 · 723 reputationPosted Apr 30, 2012, 2:28 AM EDT
MuthuMari MRank #5,738 · 288 reputationPosted Apr 30, 2012, 2:42 AM EDT
use like this
select (no1 - no2) 'subtract' from subtract
or
using self join
select a.Number1,
coalesce(a.Number1-
(select b.Number2 from tablename b ), a.Number1) as diff
from tablename
pls refer this url
http://stackoverflow.com/questions/919136/subtracting-one-row-of-data-from-another-in-sql
you have to modify conditions as per your need.
thanks.
If this post is useful then mark it as "Accepted Answer"