For example the accessing SQL Server :
#define DBNTWIN32
#include <stdio.h>
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>
int err_handler(PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
int msg_handler(PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR,
LPCSTR, DBUSMALLINT);
main()
{
PDBPROCESS dbproc; PLOGINREC login; DBCHAR name[100];
DBCHAR city[100];
dberrhandle (err_handler);
dbmsghandle (msg_handler);
dbinit ();
login = dblogin ();
DBSETLUSER (login, "my_login");
DBSETLPWD (login, "my_password");
DBSETLAPP (login, "example");
dbproc = dbopen (login, "my_server");
dbcmd (dbproc, "SELECT au_lname, city FROM pubs..authors");
dbcmd (dbproc, " WHERE state = 'CA' ");
dbsqlexec (dbproc);
if (dbresults (dbproc) == SUCCEED)
{
dbbind (dbproc, 1, NTBSTRINGBIND, 0, name);
dbbind (dbproc, 2, NTBSTRINGBIND, 0, city);
while (dbnextrow (dbproc) != NO_MORE_ROWS)
{
printf ("%s from %s\n", name, city);
}
}
dbexit ();
return (0);
}
int err_handler (PDBPROCESS dbproc, INT severity,
INT dberr, INT oserr, LPCSTR dberrstr, LPCSTR oserrstr)
{
printf ("DB-Library Error %i: %s\n", dberr, dberrstr);
if (oserr != DBNOERR)
{
printf ("Operating System Error %i: %s\n", oserr, oserrstr);
}
return (INT_CANCEL);
}
int msg_handler (PDBPROCESS dbproc, DBINT msgno, INT msgstate,
INT severity, LPCSTR msgtext, LPCSTR server,
LPCSTR procedure, DBUSMALLINT line)
{
printf ("SQL Server Message %ld: %s\n", msgno, msgtext);
return (0);
}
P.S.
You can use Data Sources Open Database Connectivity (ODBC) to access data from a variety of database management systems. For example, if you have a program that accesses data in a SQL database, Data Sources (ODBC) will let you use the same program to access data in a Visual FoxPro database. To do this, you must add software components called drivers to your system. Data Sources (ODBC) helps you add and configure these drivers. start->Settings->Control Panel->Administrative Tools->Data Sources (ODBC) Please see here:
http://msdn.microsoft.com/en-us/library/2x0tte0f.aspx