首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

求救!关于更新的有关问题.

2012-01-30 
求救!!关于更新的问题.........我想通过文本框txtpriceN把数据库中的一条记录更新,使它的 进货价 字段的

求救!!关于更新的问题.........
我想通过文本框txtpriceN   把数据库中的一条记录更新,使它的 "进货价 "字段的值等于txtpriceN的值.代码是这样写的....    
      Dim   Myconn   As   New   SqlConnection
                Dim   MyStr   As   String
                MyStr   =连接字符串
                Myconn.ConnectionString   =   MyStr
Dim   strSQL   As   String
  strSQL   =   "update   药品信息   set   进货价=   txtPriceN.Text   where   药品编号=   Me.txtId.Text   "
                Dim   MyComm   As   New   SqlCommand(strSQL,   Myconn)
                Myconn.Open()
                MyComm.ExecuteNonQuery()
运行时出现错误..   提示是这样的...

未处理的“System.Data.SqlClient.SqlException”类型的异常出现在   system.data.dll   中。

其他信息:   系统错误。

    MyComm.ExecuteNonQuery()     这行代码变绿色

正确的代码应该怎样写呢?请各位大虾帮帮忙!!!!


[解决办法]
strSQL = "update 药品信息 set 进货价= txtPriceN.Text where 药品编号= Me.txtId.Text "
不对吧
改一下
strSQL = "update 药品信息 set 进货价= " & txtPriceN.Text & " where 药品编号= " & Me.txtId.Text & "

[解决办法]
strSQL = "update 药品信息 set 进货价= txtPriceN.Text where 药品编号= Me.txtId.Text "
这一行改成
strSQL = "update 药品信息 set 进货价= txtPriceN.Text where 药品编号= " & Me.txtId.Text

热点排行