Получение ошибки преобразования nvarchar в numeric
Protected Sub AddNewRecord() Dim _connStr As String = SharedLibrary.GetConfigSetting("MRI.ConnectionString") Using conn As SqlConnection = New SqlConnection(_connStr) Dim sql As String = "Insert into TB_NABERS_SUSTAINABILITY (BldgId,UTILITY_TYPE,FRMDT,TODT,UNIT_USAGE,UNIT_TYPE,GP,WRating) values (@BLDGID,@UTILITY_TYPE,@FRMDT,@TODT,@UNIT_USAGE,@UNIT_TYPE,'0.0',@WRating)" Using cmd As SqlCommand = New SqlCommand(sql, conn) cmd.Parameters.AddWithValue("@BLDGID", BldgId.Trim()) cmd.Parameters.AddWithValue("@UTILITY_TYPE", naberText(UtilityType)) cmd.Parameters.AddWithValue("@FRMDT", DateTime.ParseExact(txtFromDate.Text.Trim(), "d/M/yyyy", CultureInfo.InvariantCulture)) cmd.Parameters.AddWithValue("@TODT", DateTime.ParseExact(txtToDate.Text.Trim(), "d/M/yyyy", CultureInfo.InvariantCulture)) cmd.Parameters.AddWithValue("@UNIT_USAGE", txtUsage.Text.Trim()) cmd.Parameters.AddWithValue("@UNIT_TYPE", naberUnit(UtilityType)) 'If txtGreenPower.Text.Trim() = "" Then ' cmd.Parameters.AddWithValue("@GP", 0.0) 'Else ' cmd.Parameters.AddWithValue("@GP", txtGreenPower.Text.Trim()) 'End If If TextWaterRating.Text.Trim = "" Then cmd.Parameters.AddWithValue("@WRating", 0.0) Else cmd.Parameters.AddWithValue("@WRating", Convert.ToDecimal(TextWaterRating.Text.Trim())) End If conn.Open() cmd.ExecuteNonQuery() conn.Close() End Using
у меня есть таблица TB_NABERS_SUSTAINABILITY column Wrating Decimal(10,2)
Что я уже пробовал:
i have the table TB_NABERS_SUSTAINABILITY column Wrating Decimal(10,2)
я также преобразовал в десятичную систему счисления