Is the n_pedido field defined as the primary key field in the database? You have to choose the actual primary key field, not just any field you want to use as the key.
I'd need to debug this one as well. If you can put it on a live server I can test and debug. If you want to sign up for a premium support ticket I can call and do screen sharing with you to work through this and any other issues you are having.