Welcome To BlitzSQL!
Version 1.1 Command Reference

BlitzSQL adds SQL functionality to Blitz through a UserLib. It's a DLL containing functions for accessing SQL databases. The DLL currently has one module supporting MySQL servers. BlitzSQL is extremely easy to use and it's free for any project!



OpenSQLStream(ipaddress$, port%, username$, password$, dbname$, servertype%)

Parameters
ipaddress = The IP address or hostname of the SQL server.
port = The port of the SQL server (MySQL's default is 3306).
username = The username to use to access the SQL server.
password = The password to use to access the SQL server.
dbname = The name of the database you wish to use.
servertype = SQL server type (see below).
Description
Attempts to open a connection with the desired SQL database. If the open command was successful, the command returns a sqlhandle. Otherwise it returns 0.

You can pick the following values for servertype,
1: MySQL server

The IP address can be in the form of 1.2.3.4 or "www.domain.com".




SQLConnected%(sqlhandle)

Parameters
sqlhandle = Handle assigned when the SQL connection was opened.
Description
Returns true when the SQL server connection is still alive and false when the connection is no longer alive.



SQLQuery(sqlhandle, query$)

Parameters
sqlhandle = Handle assigned when the SQL connection was opened. query = The SQL query to execute on the SQL server.
Description
Attempts to execute a SQL query on the specified SQL server. If the query command was succesful, the command returns a queryhandle. Otherwise it returns 0.



SQLRowCount%(queryhandle)

Parameters
queryhandle = Handle assigned when the SQL query was executed.
Description
Returns the number of rows that were affected by the query.



SQLFieldCount%(queryhandle)

Parameters
queryhandle = Handle assigned when the SQL query was executed.
Description
Returns the number of available fields that resulted from the query.



SQLFetchRow(queryhandle)

Parameters
queryhandle = Handle assigned when the SQL query was executed.
Description
Attempts to fetch the next available row. Everytime you call this function, a new rowhandle (that of the next row) is returned. If no rows are available, 0 is returned instead.



ReadSQLField$(rowhandle, fieldname$)

Parameters
rowhandle = Handle assigned when the row of the SQL query was fetched. fieldname = The name of the field you wish to grab data from.
Description
Gets the data from a given field (by fieldname) from the specified row. If you know the name of the field you need, use this command. If you don't know the field's name, use ReadSQLFieldIndex() instead.



ReadSQLFieldIndex$(rowhandle, fieldindex%)

Parameters
rowhandle = Handle assigned when the row of the SQL query was fetched. fieldindex = The index of the field you wish to grab data from.
Description
Gets the data from a given field (by fieldindex) from the specified row. If you don't know the field's name, this command is useful.

The range of the index is from 0 to fieldcount-1. Get the fieldcount with SQLFieldCount().




FreeSQLQuery(queryhandle)

Parameters
queryhandle = Handle assigned when the SQL query was executed.
Description
Free's a query result from the memory. It can no longer be used to fetch rows from.



FreeSQLRow(rowhandle)

Parameters
rowhandle = Handle assigned when the row of the SQL query was fetched.
Description
Free's a row of a SQL query from the memory. It can no longer be used to fetch fielddata from.



CloseSQLStream(sqlhandle)

Parameters
sqlhandle = Handle assigned when the SQL connection was opened.
Description
Closes a SQL connection. All queries and rows are not lost, you have to free them manually!





If you experience any problems using BlitzSQL, please contact daniel.a@home.nl.