我正在测试以下查询以更新SQL Server数据库中的列,并报告以下代码:
data1 = textbox
data2 = TextBox2
using ms as new MemoryStream ()
DirectCast (picturebox1.image, botmap) .save (ms currentFormat)
image = ms.toArray ()
end using
Dim param as SqlParameter () = _
new SqlParameter () {new SqlParameter ("@ data1", _
data1), new SqlParameter ("@ data2", data2), new SqlParameter ("@ image", image)}
mcmd.commandText = "update set table column1 = '" + data1 + "', column2 '" + data1 + "'"
mcmd.parameters.add ("@ image", SqlDbType.varbinary, 8000) .Value = image
代码行仅更新值data1
和data2
,但图片未更新
我该如何解决这个问题?
答案 0 :(得分:0)
查看下面的UPDATE
声明;它在语法上看起来并不正确,在=
column2
mcmd.commandText = "update set table column1 = '" + data1 + "', column2 '" + data1 + "'"
应该是
mcmd.commandText = "update table_name set column1 = '" + data1 + "', column2 = '" + data2 + "'"
此外,您已经声明了值的参数,因此请在UPDATE
语句中使用它们
mcmd.commandText = "update table_name set column1 = @data1, column2 = @data2