I'm getting this error while executing this code .
Code:
 Private Sub UpdateData_adapter()
        Dim fstream As FileStream
        Dim imgdata As Byte()
        Dim data As Byte()
        Dim finfo As FileInfo
        finfo = New FileInfo(Txtfilepath1.Text)
        Dim numbyte As Long
        Dim br As BinaryReader
        numbyte = finfo.Length
        fstream = New FileStream(Txtfilepath1.Text, FileMode.Open, FileAccess.Read)
        br = New BinaryReader(fstream)
        data = br.ReadBytes(numbyte)
        imgdata = data
        Dim img2 As Double
        img2 = calculate_size(finfo)
        If img2 <= 35 Then
            MessageBox.Show("This is a correct file size")
            Dim con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
            con.Open()
            
            Dim da As New SqlDataAdapter(New SqlCommand("SELECT * FROM Employee WHERE EmployerID=1", con))
            Dim ds As New DataSet
            Try
                
                da.Fill(ds, "Employee")
                If IsNothing(ds.Tables("Employee")) = False Then
                    
                    Dim dr As DataRow = ds.Tables("Employee").Rows.Add
                    With dr
                        
                        dr("Firstname") = TextBox1.Text
                        dr("Lastname") = TextBox2.Text
                        dr("Fathername") = TextBox3.Text
                        dr("Nominename") = TextBox4.Text
                        dr("Gender") = TextBox5.Text
                        dr("Address") = TextBox6.Text
                        dr("Pincode") = TextBox7.Text
                        dr("Contactnumber") = TextBox8.Text
                        dr("DOB") = DateTimePicker1.Text
                        dr("City") = TextBox9.Text
                        dr("Bankdetails") = TextBox10.Text
                        dr("Companyname") = TextBox11.Text
                        dr("Designation") = TextBox12.Text
                        dr("ESINO") = TextBox13.Text
                        dr("PFNO") = TextBox14.Text
                        dr("Basicsalary") = TextBox15.Text
                        dr("DOJ") = DateTimePicker2.Text
                        dr("DOL") = DateTimePicker3.Text
                        dr("HRA") = TextBox16.Text
                        dr("BasicofPF") = TextBox17.Text
                        dr("Conv") = TextBox18.Text
                        dr("Loanamount") = TextBox19.Text
                        dr("Bonus") = Txtbonus.Text
                        dr("Otherded") = TextBox21.Text
                        dr("Imagedata") = imgdata
                        dr("Imagepath") = Txtfilepath1.Text
                        dr("Imagename") = Txtfilename.Text
                        dr("Grosssalary") = TxtGross.Text
                        dr("Remark") = RTB1.Text
                    End With
                    'If Update
                    da.UpdateCommand = New SqlClient.SqlCommandBuilder(da).GetUpdateCommand
                    
                    da.Update(ds.Tables("Employee"))
                Else
                    MsgBox("Could not retreive table data!" & vbCrLf & "Process aborted!")
                    Exit Sub
                End If

            Catch ex As Exception
                MsgBox(ex.ToString())
            Finally
                
                con.Close()
                da.Dispose()
                ds.Dispose()
            End Try
        End If
    End Sub
And here is the screenshot of the error.

Name:  Adapter_error.jpg
Views: 243
Size:  64.2 KB