Why have you removed the GetLastError() call? MSDN says that "Thereturn value is the calling thread's last-error code".
-- Peter Geoghegan http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training and Services