Perfect Sync logoPerfect Sync
SQL Tools

SQL Tools Version 3

Sample Program

Here's the PowerBASIC source code for a simple program that opens a database, retrieves all of the data from a table called AddressBook, and exports it to a comma-and-quote-delimited text file called MyData.CSV:


#INCLUDE "SQLT3.INC"
#LINK    "SQLT3Pro.PBLIB"
 
FUNCTION PBMAIN AS LONG
    SQL_Authorize %MY_SQLT_AUTHCODE
    SQL_Init
    SQL_OpenDB    "SQLTools_Example.DSN"
    SQL_ResultSet "SELECT * FROM AddressBook","MyData.CSV"
    SQL_CloseDB
    SQL_Shutdown
END FUNCTION

That's just ten lines of code, and it's a fully functioning SQL Tools program!

Change "MyData.CSV" to a string variable like MyData$ and get string data instead of a disk file.

Change SQL_ResultSet to SQL_ResultSetArray and SQL Tools will load the contents of the table into a two-dimensional PowerBASIC string array.

Change it to SQL_ResultSetSafeArray and you'll get a PoweBASIC PowerArray object.

Use SQL_ResultColumnString(%ALL_COLs)to handle the data one row at a time.

Or use SQL_ResultColumnString(column number) to retrieve the data field by field.

SQL_ResultColumnNumeric returns numbers from Bits to Quads and from Single to Extended Precision.

SQL_ResultColumnMemo retrieves text data up to 2 gigabytes in length, and SQL_ResultColumnBLOB (SQL Tools Pro only) retrieves images, sound files, and even entire programs from a database.

There's more, but you get the idea.

And don't be fooled by the simplicity of that little program! Take another look at the SQL Tools Pro feature list and you'll see that it provides everything you'll need to build powerful, flexible, multi-user database programs. Whether you're a novice or a seasoned SQL guru, SQL Tools has what you need!

 

SQL Tools Main Page

Perfect Sync logo

UPDATED 30 JUL 2017    



About Us  Contact Us  Legal Stuff  Main Page
© Copyright 2006-2017 Perfect Sync, Inc. All rights reserved