You do not need sockets to do this. Database libraries have their own client interfaces that do the task for you. There are few abstraction layer that can be used if you are using different type of databases.
Well you can use any of the below libraries:
1. SOCI - Database Abstraction Library
2. POCO Library Database abstraction layer
These provide abstraction for dealing with different databases in a unified way from C++. I have used SOCI and it work great.
I have a windows build for SOCI using visual studio 2008 in the following location for my use. You can use it if you wish. It uses sqlite3 as database.
My SOCI 3.1 Build for Visual Studio 2008.
Let me know if you need any help.