Error converting datatype nvarchar to float

I have a sqldatareader that uses the folowing stored procedure:

SELECT convert(nvarchar,REPLACE(CONVERT(varchar(25),CONVERT(money, NULLIF(round(Actual_Exempt_Spend,0),''),NULL), 1),'.00', ''))  Actual_Exempt_Spend
FROM BUDGET_ACTUAL

The VB Part looks like this:

 rdr = cmd.ExecuteReader()
        Dim Counter As Integer = 0
        While rdr.Read
            Counter = Counter + 1
            Exit While
        End While

If Counter > 0 Then
            Me.txtASR.Text = rdr("Actual_Supplemental_Revenue").ToString
End If

When I run it throws the error converting datatype nvarchar to float.

Can anyone shed some light on this?

Thanks
JessyRobinson1234Asked:
Who is Participating?
 
tigin44Commented:
why do you try to convert in such a complex way?
0
 
tigin44Commented:
try this

SELECT convert(nvarchar,REPLACE(CONVERT(varchar(25),CONVERT(money, round(NULLIF(Actual_Exempt_Spend,''), 0),NULL), 1),'.00', ''))  Actual_Exempt_Spend
FROM BUDGET_ACTUAL
0
 
JessyRobinson1234Author Commented:
That returns a NULL value while I have a value.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
JessyRobinson1234Author Commented:
Still getting the same error
0
 
tigin44Commented:
waht do you really want to? can you give some example...
0
 
JessyRobinson1234Author Commented:
Sure. I have a form that uses the update parameter. Once the values are updated I want to go back to the same form and display the updated values (e.g. textbox was initially empty, when I go back to the record it should prepolate the value which is coming from the stored procedure through the sqldatareader.

The error Error converting data type nvarchar to float occurs at

While rdr.Read
0
 
JessyRobinson1234Author Commented:
That's a good question. It's carried over from a previous project. When I take it all out and just use the column values it works. I suppose there is a better way to do formatiing :)

0
 
JessyRobinson1234Author Commented:
I am just going to focus on functionality for now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.