Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim cmd As New OleDb.OleDbCommand
        If Not cnn.State = ConnectionState.Open Then
            'open connection if it is not yet open
            cnn.Open()
        End If

        cmd.Connection = cnn
        'check whether add new or update
        If MsgBox("Do you want save?", vbInformation + vbYesNo) = vbYes Then
            If Me.txtstdID.Tag & "" = "" Then
                'add new 
                'add data to table
                cmd.CommandText = "INSERT INTO tblResidence(ReID, Previous, Present, Reading, Amount, Total_Amount, Date) " & _
                                " VALUES('" & Me.txtstdID.Text & ",'" & _
                                Me.txtPrev.Text & "','" & Me.txtPresent.Text & "','" & _
                                Me.txtRead.Text & "','" & _
                                Me.txtAmount.Text & "','" & Me.txtTAmount.Text & "','" & _
                                Me.txtDate.Text & "')"
                cmd.ExecuteNonQuery()
            Else
                'update data in table
                cmd.CommandText = "UPDATE tblResidence " & _
                            ", ReId='" & Me.txtstdID.Text & "'" & _
                            ", Previous='" & Me.txtPrev.Text & "'" & _
                            ", Present='" & Me.txtPresent.Text & "'" & _
                            ", Reading='" & Me.txtRead.Text & "'" & _
                            ", Amount='" & Me.txtAmount.Text & "'" & _
                            ", Total_Amount='" & Me.txtTAmount.Text & "'" & _
                            ", Date='" & Me.txtDate.Text & "'" & _
                            " WHERE ReID=" & Me.txtstdID.Tag
                cmd.ExecuteNonQuery()
            End If
            'refresh data in list
            RefreshData()
            Me.ReloadRecords()
            'clear form
            Me.btnClear.PerformClick()
        ElseIf vbNo Then


        End If

        'close connection
        cnn.Close()
    End Sub

can anyone help me for this problem pls

You didn't say what line was causing the error but for starters you should change

 cmd.CommandText = "UPDATE tblResidence " & _
                 ", ReId='" & Me.txtstdID.Text & "'" & _
                 ", Previous='" & Me.txtPrev.Text & "'" & _
                 ", Present='" & Me.txtPresent.Text & "'" & _
                 ", Reading='" & Me.txtRead.Text & "'" & _
                 ", Amount='" & Me.txtAmount.Text & "'" & _
                 ", Total_Amount='" & Me.txtTAmount.Text & "'" & _
                 ", Date='" & Me.txtDate.Text & "'" & _
                 " WHERE ReID=" & Me.txtstdID.Tag

to

 cmd.CommandText = "UPDATE tblResidence " & _
                 " "   SET ReId         = '" & txtstdID.Text & "'" & _
                 ",        Previous     = '" & txtPrev.Text & "'" & _
                 ",        Present      = '" & txtPresent.Text & "'" & _
                 ",        Reading      = '" & txtRead.Text & "'" & _
                 ",        Amount       = '" & txtAmount.Text & "'" & _
                 ",        Total_Amount = '" & txtTAmount.Text & "'" & _
                 ",        Date         = '" & txtDate.Text & "'" & _
                 "   WHERE ReID         =  " & txtstdID.Tag

but you should really be using parameterized queries. The link takes you to a thread with examples for both SqlClient and OLEDB. Note that it is not necessary to add "Me." to qualify all of your textbox controls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.