Link to home
Start Free TrialLog in
Avatar of westdh
westdhFlag for United States of America

asked on

I am trying to do a select and getting this error: Error converting data type nvarchar to float.

error msg:
Exception Details: System.Data.SqlClient.SqlException: Error converting data type nvarchar to float.
----------------
both Latitude & longitude are db float values
----------------

    <asp:SqlDataSource ID="dsPopulateExtWA" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
                SelectCommand="SELECT DISTINCT  [State] + ' ' + [City] + ' ' + [Ext2] + ' ' + [Ext3]  + ' ' + Latitude
 + ' ' + Longitude AS MyDataWA
                 FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'WA'"></asp:SqlDataSource>
Avatar of Manoj Patil
Manoj Patil
Flag of India image

Try this

"SELECT DISTINCT  [State] + ' ' + [City] + ' ' + [Ext2] + ' ' + [Ext3]  + ' ' + CASE ISNUMERIC(Latitude) WHEN 1 THEN CAST(Latitude AS float) ELSE null END + ' ' + CASE ISNUMERIC(Longitude) WHEN 1 THEN CAST(Longitude AS float) ELSE null END  AS MyDataWA
FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'WA'"



Avatar of westdh

ASKER

Iam getting the same error:

Error converting data type nvarchar to float.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Error converting data type nvarchar to float.

Is there any null data or which is not float or can't covert into float.... have u checked the DB Table
Avatar of westdh

ASKER

No Nulls:

all I am doing is selecting the data and populating a dropdownlist?
ASKER CERTIFIED SOLUTION
Avatar of Manoj Patil
Manoj Patil
Flag of India 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
Avatar of westdh

ASKER

Thanks Much