You can connect to SQL Server or MSDE via ODBC, OLE DB, or DB-Library.
What you prefer to use except ODBC ?
DB-Library example code just for keywords to google.
// MSSQL database
PDBPROCESS dbproc; // The connection with SQL Server.
PLOGINREC login; // The login information.
int err_handler(PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
int msg_handler(PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR,
LPCSTR, DBUSMALLINT);
dberrhandle(err_handler);
dbmsghandle (msg_handler);
login = dblogin();
dbsetlname(login, 0, DBSETSECURE);
dbproc = dbopen(login, "local");
dbuse(dbproc, "test");
dbexit();