请教在VB.net中如何将文本框中的数值保存到数据库中money类型的字段中?
请问在VB.net中怎么将文本框中的数值保存到数据库中money类型的字段中???
下面是一段更新数据库记录的代码,目的是要将文本框txtCmdyPrice内的数值存入“商品信息表”中指定的行记录中。字段“商品价格”在数据库中为money 类型。。
请大家指教!!!
SqlConnection1.Open()
Dim comstr As String = "update 商品信息表 set 商品价格 = ' " &txtCmdyPrice.text & " ' where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
Dim sqlcom As New SqlClient.SqlCommand(comstr, SqlConnection1)
sqlcom.ExecuteNonQuery()
SqlConnection1.Close()
------解决方案--------------------
Dim comstr As String = "update 商品信息表 set 商品价格 = " & txtCmdyPrice.text & " where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
------解决方案--------------------
商品价格 = ' " + val(txtCmdyPrice.text.trim) + " '
------解决方案--------------------
'试一试下面的语句
Dim comstr As String = "update 商品信息表 set 商品价格 = @Param where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
Dim sqlcom As New SqlClient.SqlCommand(comstr, SqlConnection1)
sqlcom.Parameters.Add( "@Param ", OleDb.OleDbType.Currency ).Value = txtCmdyPrice.text
sqlcom.ExecuteNonQuery()
SqlConnection1.Close()
------解决方案--------------------
商品价格 = "&cdec(val(CDbl(txtCmdyPrice.text.trim) & " "))& "
下面是一段更新数据库记录的代码,目的是要将文本框txtCmdyPrice内的数值存入“商品信息表”中指定的行记录中。字段“商品价格”在数据库中为money 类型。。
请大家指教!!!
SqlConnection1.Open()
Dim comstr As String = "update 商品信息表 set 商品价格 = ' " &txtCmdyPrice.text & " ' where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
Dim sqlcom As New SqlClient.SqlCommand(comstr, SqlConnection1)
sqlcom.ExecuteNonQuery()
SqlConnection1.Close()
------解决方案--------------------
Dim comstr As String = "update 商品信息表 set 商品价格 = " & txtCmdyPrice.text & " where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
------解决方案--------------------
商品价格 = ' " + val(txtCmdyPrice.text.trim) + " '
------解决方案--------------------
'试一试下面的语句
Dim comstr As String = "update 商品信息表 set 商品价格 = @Param where 商品编号= ' " & DataGridView2.Rows(DataGridView2.CurrentRow.Index).Cells(0).Value & " ' "
Dim sqlcom As New SqlClient.SqlCommand(comstr, SqlConnection1)
sqlcom.Parameters.Add( "@Param ", OleDb.OleDbType.Currency ).Value = txtCmdyPrice.text
sqlcom.ExecuteNonQuery()
SqlConnection1.Close()
------解决方案--------------------
商品价格 = "&cdec(val(CDbl(txtCmdyPrice.text.trim) & " "))& "