Link to home
Start Free TrialLog in
Avatar of JessyRobinson1234
JessyRobinson1234

asked on

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
Avatar of tigin44
tigin44
Flag of Türkiye image

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
Avatar of JessyRobinson1234
JessyRobinson1234

ASKER

That returns a NULL value while I have a value.
Still getting the same error
waht do you really want to? can you give some example...
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
ASKER CERTIFIED SOLUTION
Avatar of tigin44
tigin44
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 :)

I am just going to focus on functionality for now.