i have make this program to update database.but it have something error.
pop up show this message "An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: ExecuteNonQuery requires an open and available Connection. The connection's current state is Closed.
"
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
Try
If txtUserName.Text <> "" Then
OleDbDataAdapter1.UpdateCommand.CommandText = _
"UPDATE addresses SET PinCode= '" & txtPinCode.Text & "' , " & _
"Occupation= '" & txtOccupation.Text & "' , " & _
"Balance='" & txtBalance.Text & "' , " & _
"Age='" & txtAge.Text & "' , " & _
"WHERE UserName=" & txtUserName.Text & " ; "
txtStatus.Text &= vbCrLf & "Sending query: " & _
OleDbDataAdapter1.UpdateCommand.CommandText & _
vbCrLf
txtStatus.Text &= vbCrLf & "Query Successful" & _
vbCrLf
OleDbDataAdapter1.UpdateCommand. _
ExecuteNonQuery()
Else
txtStatus.Text &= vbCrLf & _
"You may only update an existing record. "
End If
Catch exception As System.Data.OleDb.OleDbException
Console.WriteLine(exception.StackTrace)
txtStatus.Text &= exception.ToString
End Try
End Sub