It depends on the database. Oracle, for instance, offers the Pro*C precompiler environment. SQL Server is via DMO or earlier, ADO. Most DB's have some sort of API to let you access their data.
-------------------------
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright