• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

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
0
JessyRobinson1234
Asked:
JessyRobinson1234
  • 5
  • 3
1 Solution
 
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
 
JessyRobinson1234Author Commented:
Still getting the same error
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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
 
tigin44Commented:
why do you try to convert in such a complex way?
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now