I found some C++ codes for accessing DB2 but it was very complicated and has used lots of functions.It's address is :
www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v7pubs.d2w/en_main