Duplicate Records

I have a application running with PostgreSQL i have two computer and one server this runs using internet and when i save the data it duplicate the data with the same data on the server from two different computer.

Is like double insert of the data with the same data from difference computer but is no the same data

I don’t think that the issue is linked specifically to PosgreSQL. I would rather suspect that the issue would happen with any other database also. Without more information and from the top of my head, I can see only three likely scenarios:

1- if both database entries are supposed to be valid, then you should probably analyse the key that you defined for your table, It is probably missing a field or more.

2- if only one record is supposed to be valid, then you may want your app to first check whether the record exists, and if it does, update the record rather than create a new one.

3- If both value sets could be valid and they should also still be only one record, then you have synchronization issues and you need to think about the architecture of the app. You may first need to refresh the client data before doing any processing.

I hope that this can help you resolve your issue.

To refresh the data i have to close the connection and open it to load the data

No, not necessarily. It really depends on your application, and it is very difficult to be specific with what we have.

I am thinking along the way of methods that update the underlying classes or the UI elements prior to allowing processing. If your app expects several users to work concurrently on the same records, then you must also think about record locking, and about verification methods. By that, I mean that if many different people can work on or update the same data concurrently, then your app should only allow one in edit mode at any given time, others having only read access. Next to that, if this approach is too stringent, then your app should check for updates and warn the user in case the data was already modified, and allow the user to update his data set. That can however prove difficult to manage.