1、改成
cmd.Parameters.Add("@photo", ImageByte)
完整这样写
Dim cmd As new SQLCommand
cmd.ConnectionName = "test"
cmd.CommandText = "Insert Into test (img) Values(?)"
Dim fs As New IO.FileStream("D:\test.JPG" , IO.FileMode.Open , IO.FileAccess.Read) '用文件流打开图片
Dim br As New IO.BinaryReader(fs) '根据文件流,申明一个二进制阅读器
Dim ImageByte() As Byte = br.ReadBytes(fs.Length) '阅读器读取文件流,并将独到的二进制放入数组ImageByte中,
'Dim ImageString As String = BitConverter.ToString(imageByte).Replace("-", "") ' SQLCommand 不能直接Insert 二进制,只能拼接SQL语句,所以这里把二进制变成字符
cmd.Parameters.Add("@图片", ImageByte)
cmd.ExecuteNonQuery