LitDev Extension API

GW LD3DView LDArray LDBits LDBlueTooth
LDCall LDChart LDClient LDClipboard LDColours
LDCommPort LDController LDControls LDCursors LDDataBase
LDDateTime LDDebug LDDialogs LDDictionary LDEffect
LDEmail LDEncryption LDEvents LDFastArray LDFastShapes
LDFigures LDFile LDFinances LDFocus LDftp
LDGeography LDGraph LDGraphicsWindow LDHashTable LDHID
LDIcon LDImage LDInline LDIOWarrior LDList
LDLogic LDMath LDMathX LDMatrix LDMusic
LDNetwork LDPhysics LDProcess LDQueue LDRegex
LDResources LDScrollBars LDSearch LDServer LDSettings
LDShapes LDShell LDSort LDSound LDSpeech
LDStatistics LDStopwatch LDText LDTextWindow LDTimer
LDTranslate LDUnits LDUtilities LDVector LDWaveForm
LDWebCam LDWindows LDxml LDZip TW

LDDataBase
SQL Database with ListView control.
ConnectSQLite for SQLite databases (see http://zetcode.com/db/sqlite for SQLite commands).
ConnectMySQL for MySQL databases (see http://www.mysql.com for MySQL downloads and setup).
ConnectSqlServer for SqlServer databases (see http://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/sql-server-express.aspx for SqlServer downloads and setup).
ConnectOleDb for Access OleDb databases.
ConnectOdbc for Odbc databases.


AddListView Command Connection
ConnectMySQL ConnectOdbc ConnectOleDb
ConnectSQLite ConnectSqlServer EditTable
GetDB Query SaveTable
SaveTableBySQL

AddListView(width,height)
Add a ListView to view database query results.
This is a read only display of query results.

width The width of the ListView.
height The height of the ListView.
returns The ListView control.

Command(database,command)
Perform an SQLite, MySQL, SqlServer. OleDb or Odbc command (not a query) on a database.
If this database is viewed in a dataview then unsaved user changes will be lost when the dataview is updated following this operation.

database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
command The SQL Command.
returns The number of rows updated.

Connection
Over-ride an SQL database connection string (advanced use only).
Set before connection to database, when this connection string will be used in place of the entered connection parameters.
Default is "" (unused).


ConnectMySQL(server,user,password,database)
Connect to a MySQL database.
This must be called before any SQL methods.
The MySQL service must be running and database with credentials already created, if in doubt use SQLite.

server The MySQL server (e.g. "localhost").
user The MySQL user name.
password The MySQL user password.
database The MySQL database name.
returns A label to identify the database.

ConnectOdbc(driver,server,port,user,password,option,database)
Connect to an Odbc driver connected database.
This must be called before any SQL methods.
The Odbc service must be running and database with credentials already created, if in doubt use SQLite.

driver The Odbc driver (e.g. "{MySQL ODBC 3.51 Driver}").
server The Odbc server (e.g. "localhost").
port The Odbc port number.
user The Odbc user name.
password The Odbc user password.
option The Odbc option number to control the Odbc connection (e.g. 0 or 3).
database The Odbc database name.
returns A label to identify the database.

ConnectOleDb(provider,server,database)
Connect to an Access OleDb database.
This must be called before any SQL methods.
The Access OleDb service must be running and database with credentials already created, if in doubt use SQLite.

provider The OleDb provider (e.g. "SQLOLEDB").
server The OleDb server (e.g. "localhost").
database The OleDb database name.
returns A label to identify the database.

ConnectSQLite(fileName)
Create or open an SQLite database.
This must be called before any SQL methods.
When a table is created it must have first column as "Id INTEGER PRIMARY KEY".

fileName The full path to the SQLite database file (usually with extension db).
returns A label to identify the database.

ConnectSqlServer(server,database)
Connect to a SqlServer database.
This must be called before any SQL methods.
The SqlServer service must be running and database with credentials already created, if in doubt use SQLite.

server The SqlServer server (e.g. "(local)\SQLEXPRESS").
database The SqlServer database name.
returns A label to identify the database.

EditTable(database,table,dataview)
Display a database table for editing in a LDControls.DataView control.
Using this method the database is bound to the dataview conrol, reflecting the database.

database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
table The table name to view and edit.
dataview A DataView control.
returns "SUCCESS" or "FAILED".

GetDB()
Get a read only list of databases for use outside Small Basic.
returns IReadOnlyList

Query(database,query,listview,getRecords)
Perform an SQLite, MySQL, SqlServer, OleDb or Odbc Query (not a command) on a database.
database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
query The SQL Query.
Example "SELECT * FROM myTable;".

listview A ListView to populate with the query result or "" for none.
getRecords Optionally return an array of results ("True" or "False").
Remember large multi-dimensional arrays in Small Basic are slow.

returns Optional array of results or "".

SaveTable(database,dataview)
Commit any changes made in a LDControls.DataView to the database.
database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
dataview A DataView control.
returns "SUCCESS" or "FAILED".

SaveTableBySQL(database,dataview)
Commit any changes made in a LDControls.DataView to the database.
This is an alternative to SaveTable, where the data binding fails for some reason.
This method may be slower than SaveTable, since it recreates the table line by line using SQL.

database The existing database label (see ConnectSQLite, ConnectMySQL, ConnectSqlServer, ConnectOleDb or ConnectOdbc).
dataview A DataView control.
returns "SUCCESS" or "FAILED".