查询SQL更新列图像

时间:2014-10-27 08:09:12

标签: sql sql-server image sql-update

我正在测试以下查询以更新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 

代码行仅更新值data1data2,但图片未更新

我该如何解决这个问题?

1 个答案:

答案 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