What else could be the reason of this error? The code is probably correct, because it worked on different server. I'm thinking about permissions - can it be, that I need extra permissions on SharePoint or on SQL server?
I'm able to add file to the list in UI (in browser) without problems. I'm using Claims Based Authentication. My user (with Windows identity) has Full Control permissions on Web Application.