westdh
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.SqlE xception: Error converting data type nvarchar to float.
----------------
both Latitude & longitude are db float values
----------------
<asp:SqlDataSource ID="dsPopulateExtWA" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlS erver %>"
SelectCommand="SELECT DISTINCT [State] + ' ' + [City] + ' ' + [Ext2] + ' ' + [Ext3] + ' ' + Latitude
+ ' ' + Longitude AS MyDataWA
FROM [trip4usdnn].[trip4usdnn]. [Netism_Ma pExtreme_L ocations] where state = 'WA'"></asp:SqlDataSource>
Exception Details: System.Data.SqlClient.SqlE
----------------
both Latitude & longitude are db float values
----------------
<asp:SqlDataSource ID="dsPopulateExtWA" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlS
SelectCommand="SELECT DISTINCT [State] + ' ' + [City] + ' ' + [Ext2] + ' ' + [Ext3] + ' ' + Latitude
+ ' ' + Longitude AS MyDataWA
FROM [trip4usdnn].[trip4usdnn].
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.SqlE xception: Error converting data type nvarchar to float.
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.SqlE
Is there any null data or which is not float or can't covert into float.... have u checked the DB Table
ASKER
No Nulls:
all I am doing is selecting the data and populating a dropdownlist?
all I am doing is selecting the data and populating a dropdownlist?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For more information chekc following link
http://aartemiou.blogspot. com/2009/0 7/error-co nverting-d ata-type-v archar-to. html
http://aartemiou.blogspot.
ASKER
Thanks Much
"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].