# Visual Basic > Visual Basic .NET >  Powerful  and flexible VB access dataase with few error messages ... help

## Tajaldeen

Hello guys 
i'm new to this forum, in the link below you can download my latest Project which is a VB access database form you can throught it insert some information icluding picture and save them directly to access database, everything is flexable and fast except some error messages appears from time to time especially when i try to edit and update picture for someone.
i put the screen shot to these error in the links below.
please , anyone has similar problem could help me, i will be greatful



error messages
https://ibb.co/brL1Hbx

it appears in this coude:



```
      Try


            Dim Mypicture As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)

            With OpenFileDialog1
                .Filter = " jpg, jpeg Image|*.jpg;*.jpeg|PNG Image|*.png|BMP Image|*.bmp|" & " All files (*.*)|*.*"
                .FileName = ""
                .AddExtension = True
                .FilterIndex = 1
                .Multiselect = False
                .ValidateNames = True
                .InitialDirectory = Mypicture
                .RestoreDirectory = True

                If (.ShowDialog = DialogResult.OK) Then
                    Pic.Image = Image.FromFile(OpenFileDialog1.FileName)
                Else
                    Return

                End If
            End With

        Catch ex As Exception

        End Try

    End Sub
```


https://ibb.co/KD7kDM3
and this oune appears in this coude 



```

 If TextBox1.Text = "" And TextBox2.Text = "" Then   ' إذا كان حقل الرقم والاسم فارغين اظهر رسالة لا توجد بيانات لتعديلها


            MsgBox("لا توجد بيانات لتعديلها", MsgBoxStyle.Information, "تنبيه")

        Else   ' اما إذا كانوا يحتوون على بيانات



            Dim Cmd As New OleDbCommand
            With Cmd
                .Connection = con
                .CommandType = CommandType.Text
                .CommandText = "Update Taj Set EmpName = @EmpName,Gender = @Gender,Nationalty = @Nationalty,Phone = @Phone,Pic = @Pic Where Emp_ID = @Emp_ID"
                .Parameters.Clear()
                .Parameters.AddWithValue("@EmpName", OleDbType.VarChar).Value = TextBox2.Text
                .Parameters.AddWithValue("@Gender", OleDbType.VarChar).Value = ComboBox1.Text
                .Parameters.AddWithValue("@Nationalty", OleDbType.VarChar).Value = ComboBox2.Text
                .Parameters.AddWithValue("@Phone", OleDbType.Integer).Value = TextBox4.Text
                Dim ms As New MemoryStream()
                Dim bmpImage As New Bitmap(Pic.Image)
                bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
                Dim data As Byte() = ms.GetBuffer()
                Dim p As New OleDbParameter("@Pic", OleDbType.LongVarBinary)
                p.Value = data
                .Parameters.Add(p)
                .Parameters.AddWithValue("@Emp_ID", OleDbType.Integer).Value = TextBox1.Text
            End With
            If con.State = 1 Then con.Close()
            con.Open()
            Cmd.ExecuteNonQuery()
            con.Close()
            MsgBox("تم تعديل السجل بنجاح", MsgBoxStyle.Information, "تعديل")
            Cmd = Nothing


        End If




        RefreshData() ' دالة إضافة البيانات بشكل تلقائي 


        TextBox1.Clear()
        TextBox2.Clear()
        ComboBox1.Text = Nothing
        ComboBox2.Text = Nothing
        TextBox4.Clear()
        Pic.Image = Pic.InitialImage
```

----------


## Shaggy Hiker

Posting a compressed project is not going to work. For one thing, we don't allow compiled code, only source code. Even that isn't the best way to get an answer. For that, paste just the relevant code into your post surrounded by [CODE][/CODE] tags, which you can do using the # button.

Images are often not all that useful, but in this case, your second image certainly shows something. Any time you do anything with a database (reading/writing/altering) you need to wrap that code in exception handlers. In that second image, you probably just have an issue with the query itself, and once you get that sorted out, the error will go away, but you can never be entirely certain that all will be well when you execute a query. This is especially true with Access databases, as a person might easily have Access running at the same time, which can lock parts of the database and cause the program to malfunction. It's just safer to wrap any database work in exception handling.

----------


## Tajaldeen

*Okay, sorry about that ....
i provide the code as you menstioned , hope that will get something
*

----------

