我试图用以下代码更新基于id的blob字段,但它总是插入Null

 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        openconnection()
        Dim cmd As New Odbc.OdbcCommand("UPDATE blob_table SET image=@PictureBox1 WHERE id='6'", myconnection)
        Dim fs As New System.IO.FileStream("E:\Untitled.png", IO.FileMode.Open, IO.FileAccess.Read)
        Dim b(fs.Length() - 1) As Byte
        fs.Read(b, 0, b.Length)
        fs.Close()
        Dim P As Odbc.OdbcParameter = New Odbc.OdbcParameter("@PictureBox1", Odbc.OdbcType.Image, b.Length, ParameterDirection.Input, True, 0, 0, Nothing, DataRowVersion.Current, b)
        cmd.Parameters.Add(P)
        openconnection()
        cmd.ExecuteNonQuery()
        closeconnection()
    End Sub

我检查连接,它正常工作,
映像路径是有效路径。有人能帮我找出查询中的错误吗?

最佳答案

我认为需要将@PictureBox1的值设置为一个字节数组,例如byte[],因为我知道这是image blob类型映射到的,而不是byte。

关于mysql - 为什么跟随更新查询总是更新空值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25008554/

10-17 02:45