Have a look at the following pages:
1. For Visual C++
2. For .NET
MSDN is not really that helpful, it has all the function definitions but no proper example. You can try the link below for a simple example that will get you started.
Connecting To SQL Server Using C++ ODBC Example