Hi,
Does anybody have an idea why
Convert.ToDecimal(command5.ExecuteScalar())
returns nothing in my C# code?
I have a stored procedure which when tested returns good result, but when I call the procedure from my c# application,
......
.......
decimal saldo=Convert.ToDecimal(command5.ExecuteScalar())
when debugging I can see that saldo shows no value.
I would appreciate any idea
Loading
Jignesh TrivediPosted Jul 18, 2012, 5:15 AM
I think Problem with datatype change it to numeric(12,3)
try..
ALTER procedure [dbo].[presmetajSaldo]
(
@data DateTime,
@saldo numeric(12,3) output
)
as
Declare @priem numeric(12,3)
Declare @isplata numeric(12,3)
set @data='2012.07.12'
select @priem = sum(iznosden) from blag
where data=@data
set @saldo = isnull(@saldo,0) + (isnull(@priem,0)) - (isnull(@isplata,0))
update Kasovizvestaj
set saldo = @saldo
where
NelPosted Jul 19, 2012, 5:02 AM
NelPosted Jul 18, 2012, 4:48 AM
Here is my code again for the sp:
ALTER procedure [dbo].[presmetajSaldo]
(
@data DateTime,
@saldo decimal output
)
as
Declare @priem decimal
Declare @isplata decimal
set @data='2012.07.12'
select @priem = sum(iznosden) from blag
where data=@data and vp>=0 and vp<=10
select @isplata = sum(iznosden)
from blag
where vp>10 and data=@data
update Kasovizvestaj
set
saldo = isnull(@saldo,0.0) + (isnull(@priem,0.0)) - (isnull(@isplata,0.0))
where data=@data
select saldo from Kasovizvestaj
return
So the bolded line I suppose is the problem, which returns only the int part but not the decimal part (399.400). How to change it?
Jignesh TrivediPosted Jul 17, 2012, 6:26 AM
Are you go with "out" in SP?
check datatype of your out parameter is might be int or any where in your SP it cast in int.
check it and let me know.
also share your SP and code.
hope this will help you.
NelPosted Jul 17, 2012, 5:37 AM
For example, the real result should be 399.400, and it shows 399.000 instead.
Do you have an idea, what is my mistake? Can you tell me please?
Thanks again a lot.
Jignesh TrivediPosted Jul 13, 2012, 8:02 AM
Please refer below link.
I think it is solution for your problem
http://www.4guysfromrolla.com/articles/062905-1.aspx
http://social.msdn.microsoft.com/Forums/zh/sqlexpress/thread/fe2a209a-8f6c-4d0f-b755-a5280cd6712e
hope this will help you.
Santhosh Kumar JayaramanPosted Jul 13, 2012, 8:02 AM