Accessing DBF-files from wcBASIC programs
Use ODBC using the wcODBC.wcc/wch library module.
Please note, there is not much documentation. It is assumed you know how to use ODBC and SQL commands.
Here is an example program to print records. I did this out of the top of my head so I don't know it will work, but it should disregarding first hand typos and logic.
//------------------------------------------------------------- // example: dbfprint.wcc // // Print out the records in PEOPLE.DBF in
// ODBC DNS called MYDATABASE //
#include "wcodbc.wch"
// // open a ODBC connection to DSN (Data Set Name) called MYDATABASE
// Use ODBC32 in control panel to create the proper DSN. If you // have ODBC32, download the lastet MDAC from Microsoft Web Site. //
// NOTE: You must close "CONN" when you are done.
dim conn as long = odbcconnect("MYDATABASE","","") if conn = 0 then
print "error connecting to DNS" end end if
// // Issue ODBC SQL command to fetch all records in the
// table called PEOPLE.DBF. In this case, we are only // only to read two fields. Note that your SQL Select
// command will define what is "read" into the ODBC // internal buffers. When using OdbcResultString(), // it is assumed the requested fields were fetched in
// the select command. //
dim cName as string dim cPhone as string dim result as long result = odbcexec(conn, "select distinct * from people.dbf")
if result then do while odbcfetchrow(result,0) cName = odbcresultstring(result,"name")
cPhone = odbcresultstring(result,"phone") print cName;" ";cPhone loop if result then odbcfreeresult(result)
end if odbcclose(conn)
|
© 2002 Hector Santos, http://www.santronics.com
|