Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
select sum(amount) from table1 select sum(amt) from table 2
temp-> X temp-> Y


how to store the SUM to X and Y .

( Y - X )= -+Z
if
Z(amount) is in positive then( insert/update of data )
else
close connection
response("Budget Amount is less , cannot allow more transaction");

I am working in a project using ASP.Net (C#)

please help me with this problem
Posted
Comments
KaushalJB 11-Sep-14 7:52am    
Its your homework right ?... Search how to develop CRUD operations in C#. You would get some guidance. Here we are not for providing logics or codes.
10923679 12-Sep-14 2:46am    
You are not are to provide logics or code..
then how will help people here.. ??

this is not my homework .
i am working in a project ..
and i got stuck in this place..
anyway people out here.. helped me ..
and thanks to you as well for your guidance
"develop CRUD operations in C#."
have a nice day .
Nandakishore G N 11-Sep-14 10:18am    
Paste, What have you done till now? and come back if needed with some guidance.
10923679 12-Sep-14 0:08am    
okay thank you.. i have tried .. but i am getting on the value of x and y..

i am here to know that how should i do this in asp.net(c#) and backend is sql server .

if you can please help me with this.

If you are writing thls logic in a stored procedure then you can create variables in T-SQL and assign the totals to the variables

SQL
select @x = sum(amount) from table1
 
Share this answer
 
Comments
10923679 12-Sep-14 0:09am    
alright.. i am not working in T-SQL.
i am using SQL Server.. if u can please tell me how to use this process in asp.net(c#) and backend is sql server .
SQL
set @z=0

set @x = select sum(isnull(amount,0)) from table1
set @y = select sum(isnull(amount,0)) from table2
set @z=@y-@x

id @z<0
begin
"Failed Result"
end

else
begin
"Success Result"
end
 
Share this answer
 
v2
Comments
10923679 12-Sep-14 0:09am    
thank you.. let me try with this.
10923679 12-Sep-14 1:33am    
it is not working....
/\jmot 12-Sep-14 1:42am    
what's the error??
10923679 12-Sep-14 1:43am    
There is insufficient result space to convert a money value to int.
10923679 12-Sep-14 1:47am    
i want to perform this steps in Charp(ASP.net) backend sqlserver

variable = x, y, z, A;

x= total sum from table1

y total sum from table2

y-x=z(some amount )

if (Z>A)
{
then query =update/delete/ msg etc
}
else
response.write ("cant update.. amount is more..");
}
con.close();


can u tell me this in Charp (asp.net )
try
{
SqlConnection con = new SqlConnection(con_str);
con.Open();

decimal z = 0;

SqlCommand cmd10 = new SqlCommand("select SUM(Amount) from table1", con);
decimal x = cmd10.ExecuteNonQuery();

SqlCommand cmd11 = new SqlCommand("select SUM(Amount) from table2 ", con);
decimal y = cmd11.ExecuteNonQuery();

SqlCommand cmd12 = new SqlCommand("select SUM(Amount) from table3 ", con);
decimal a = cmd12.ExecuteNonQuery();

z = y - x;
if (z > a)
{
Label2.Text = "Rs."+z.ToString();

SqlCommand cmd3 = new SqlCommand("update query ", con);
int l = cmd3.ExecuteNonQuery();
Response.Write("Record is updated");
}
else
{
Label2.Text = "Not Working!";
}
con.Close();

}
catch (Exception ex)
{
Response.Write(ex.Message);

}
finally
{

}
 
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