Click here to Skip to main content
16,014,662 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Select SUM(TotalPrice) FROM inventoryout where Newsales=@two

C#
cmd.Parameters.AddWithValue("@two", SqlDbType.Decimal);
Posted

1 solution

AddWithValue takes the actual value as second parameter, not the Type of the value. So, assuming the column "Newsales" is of Type Int32, this would be valid:
C#
int newsales = 1;
cmd.Parameters.AddWithValue("@two", newsales);
 
Share this answer
 
Comments
_bluRe_ 8-Mar-15 11:17am    
is my select sum function correct?
[no name] 8-Mar-15 11:26am    
Yes - or to be more specific: What it will do is to produce the sum of all TotalPrice of those records in the table that have Newsales = @two . If that is what you want, then it's correct.
_bluRe_ 8-Mar-15 11:44am    
how can i put a selec sum query inside an insert query?
[no name] 8-Mar-15 11:52am    
Don't know, I've never done that.

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