贴段vb.net代码sql="update table set photo=@photo where id=1" '你的代码
fs = New FileStream(strPicFile, FileMode.Open, FileAccess.Read)
Dim Data(fs.Length) As Byte
fs.Read(Data, 0, Int(fs.Length))
'参数
Dim prm1 As New SqlParameter("@photo", SqlDbType.VarBinary, Int(fs.Length), ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, Data)
MyCmd.Parameters.Add(prm1)
fs.Close() : fs = Nothing
cmd.ExeNonQuery(sql)
fs = New FileStream(strPicFile, FileMode.Open, FileAccess.Read)
Dim Data(fs.Length) As Byte
fs.Read(Data, 0, Int(fs.Length))
'参数
Dim prm1 As New SqlParameter("@photo", SqlDbType.VarBinary, Int(fs.Length), ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, Data)
MyCmd.Parameters.Add(prm1)
fs.Close() : fs = Nothing
cmd.ExeNonQuery(sql)
更新现有 text、ntext 或 image 字段。使用 UPDATETEXT 在适当的位置更改 text、ntext 或 image 列的一部分。使用 WRITETEXT 来更新和替换整个 text、ntext 或 image 字段。语法
UPDATETEXT { table_name.dest_column_name dest_text_ptr }
{ NULL | insert_offset }
{ NULL | delete_length }
[ WITH LOG ]
[ inserted_data
| { table_name.src_column_name src_text_ptr } ]