Error: Error converting data type nvarchar to float in ASP.Net

Last Reply on Jul 05, 2017 03:34 AM By Naresh.rj

Posted on Jul 04, 2017 09:15 AM

hi

in database is Estate_info table that has column==Area with datatype=float

in edit.aspx page I define textbox that can change Area column in database:

below is code:

  _cmd.Parameters.AddWithValue("@zirbana", TxtzirB.Text);

but belwo error happen:

Server Error in '/' Application.


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. Source Error:

Line 1369:                _cmd.Parameters["@Success"].Direction = ParameterDirection.Output;
Line 1370:
Line 1371:                _cmd.ExecuteNonQuery();
Line 1372:                lblErrorSubmit.Text = _cmd.Parameters["@Success"].Value.ToString();
Line 1373:            }

 

how I can insert textbox text into database

best regards

 neda

 

 

 

 

Posted on Jul 04, 2017 09:15 AM
nedash says:
TxtzirB.Text

 Share the value of TxtzirB.Text


Posted on Jul 04, 2017 02:54 PM
dharmendr says:
 Share the value of TxtzirB.Text

 it will be number

like 50.5 or 50


Posted on Jul 05, 2017 02:31 AM
nedash says:
_cmd.Parameters.AddWithValue("@zirbana", TxtzirB.Text);

 Replace with the below code.

_cmd.Parameters.AddWithValue("@zirbana", Convert.ToDouble(TxtzirB.Text));

 


Posted on Jul 05, 2017 03:34 AM

Hi Nedash,

Try using this 

 

_cmd.Parameters.AddwithValue("@zirbana",Convert.ToDouble(TxtzirB.Text));