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 TrivediRank #16 · 50.3K reputationPosted Jul 18, 2012, 1:15 AM EDT
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
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 13, 2012, 4:02 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 13, 2012, 4:02 AM EDT
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.
NelRank #2,060 · 702 reputationPosted Jul 17, 2012, 1:37 AM EDT
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 TrivediRank #16 · 50.3K reputationPosted Jul 17, 2012, 2:26 AM EDT
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.
NelRank #2,060 · 702 reputationPosted Jul 18, 2012, 12:48 AM EDT
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?
NelRank #2,060 · 702 reputationPosted Jul 19, 2012, 1:02 AM EDT