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


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






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));