无法保存另一个用户锁定的电流

时间:2016-11-16 08:37:30

标签: sql vb.net ms-access

当我尝试浏览并选择一些图像到图片框然后我点击更新按钮

弹出错误信息,显示无法保存当前由其他用户锁定。

If lblTable.Text = "Visitor_ApplyPass" Then
    Dim fsr As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
    Using br As New BinaryReader(fsr)
        Dim imgbuffer(fsr.Length) As Byte
        br.Read(imgbuffer, 0, fsr.Length)
        fsr.Close()
        Using con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=..\VisitorPass.accdb")
            con.Open()
            Dim sql As String
            sql = "Update " & lblTable.Text & " set Visitor_Name='" & txtName.Text & "',[Visitor_Photo]= @imgfile where [VisitorApply_ID]=" & lblID2.Text & ""

            Using cmd As New OleDbCommand(sql, con)

                cmd.Parameters.AddWithValue("@imgfile", imgbuffer)

                cmd.ExecuteNonQuery()
                MsgBox("profile is updated")
                con.Close()
            End Using
        End Using
    End Using
    Me.Close()

0 个答案:

没有答案