` Better SQL Part 9 (Dan Pressnell) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

SQL Related Articles: Better SQL Part 9
2002-10-19 -- Dan Pressnell
 
The techniques that I described earlier in similar posts can be wrapped up into an object. I've done so in the form of an INTERFACE.
 
You can download the package at http://www.icetips.com/downloadfile.php?FileID=59 Look in the cwodbc.inc file for instructions on setting it up. There is also a project (PRJ) that illustrates some of the techniques that you can use with the cwodbc object.
 
I intend to write a help system documenting fully the workings of the cwodbc object. But I haven't had much time, and documenting the use of an INTERFACE is more of a chore than some people think, because interfaces can be used in so many ways.
 
The cwodbc object allows you to do the following, among other things:
 
1. Send a query and process the results on a row by row basis.
 
2. Get the column values from a query by position.
 
3. Get the column values from a query by name.
 
4. Get the names of the columns that are returned by a query.
 
5. Get the names of the tables (and views) on the server.
 
6. Get the columns and types for a table.
 
7. Easily fill queues with the results of queries. There is even one method that will let the queue structure write part of your SQL.
 
8. Retrieve TEXT, and IMAGE data. (Yay!)
 
The cwodbc object relies very heavily on the functionality that is provided by the drivers supplied with Clarion. I have tested it with ODBC and with Clarion's native MSSQL driver, and it works equally well with each. It should work with all the SQL drivers that Clarion provides, except for Oracle. It may work with the ODBC driver for Oracle, though.
 
In addition to the functionality that is provided by Clarion's drivers, the cwodbc object makes a few ODBC API calls to expose some additional features that you can use in your program (like getting the type of a column).
 
I have been advised to sell this, by several people, including my wife. But I want to make it available to all Clarion programmers, so it is freeware. All the source code is included, and it is all pure Clarion source code. (CW55 is required at a minimum). With this package, you can now access SQL databases like the big guys do with things like OLE DB and ADO, although in a less robust way, and do it all with nothing more than what comes out of the box with Clarion.
 
I have two requests. If you redistribute the package, do it with the original package. If you have modifications that you think are neat, let me know, but let's not have several dozen variations floating around without my permission.
 
Also, if you have comments or suggestions (or questions), put them in the newsgroups for Clarion. I want everybody to benefit, and that won't happen if I'm answering a lot of questions in private email.
 

Compiling the sample

 

 
Compiling the sample is simple, but here is what I did:
 
  1. Copy the ODBC32.LIB file to the \Lib directory
  2. Copy the CWODBC.CLW and CWODBC.INC to the \LibSrc directory
  3. Run Clarion
  4. Use "Project|Set Project" to load the CWSQL.PRJ file then compile it. This compiles the CWODBC.clw file and links in the odbc32.lib to create cwsql.dll which is used by the sample.
  5. Use "Project|Set Project" to load the SAMPLE1.PRJ file then compile it and run.
You can now access the cwodbc.mdb file using the ODBC driver.


Today is April 25, 2024, 1:25 am
This article has been viewed 35121 times.
Google search has resulted in 146 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: