asgsqlite3.pas
来自「DELPHI 访问SQLITE3 数据库的VCL控件」· PAS 代码 · 共 1,276 行 · 第 1/5 页
PAS
1,276 行
- changed all showmessages to raise event types
- added readonly property
feb 21, 2005 Release 2005.02.A Albert Drent (c) 2003 .. 2005 Aducom Software
- some bugfixes, code optimization
- first implementation of IProvider support (thanks to
Rocco Barbaresco)
- changed default SDB extension to SQB
- support for multi sql statements in one string
- added master-detail functionality on insert of
new child record (key-data is copied)
- added compatibility with SQLite3.dll version 3.1.2
feb 28, 2005 Release 2005.02.B Albert Drent (c) 2003 .. 2005 Aducom Software
- bugfix for filter on master-detail. Setting filtered will
not automatical open table any more. Causes error on closed
tables in master-detail otherwise.
mar 7, 2005 Release 2005.03.A Albert Drent (c) 2003 .. 2005 Aducom Software
- bugfix for memofields causing crlf to be handled wrongly
- added TableExists function ('// DI Ralf http://www.yunqa.de/delphi/)
- some code optimizations ('// DI Ralf http://www.yunqa.de/delphi/)
- solved decimalpoint bug ('// DI Ralf http://www.yunqa.de/delphi/)
mar 10, 2005 Release 2005.03.B Albert Drent (c) 2003 .. 2005 Aducom Software
- more code optimizations
- removed Forms from uses list to decrease codesize of console app's
- changed cursorstyle handling
- changed exception handling
mar 29, 2005 Release 2005.03.C Albert Drent (c) 2003 .. 2005 Aducom Software
- removed default pragma's for tables
- implemented another solution for tableheader duplicates (mirko)
- implemented user version
- solved minor bug in GetTableInfo
april 5, 2005 Release 2005.04.A Albert Drent (c) 2003 .. 2005 Aducom Software
- fixed bug conceirning in-memory database (Bert Verhees)
- fixed precompiler settings for Delhpi 7 (Dak)
mai 31, 2005 Release 2005.05.A Albert Drent (c) 2003 .. 2005 Aducom Software
- UTF8 support (thanks to Bilgehan KUYUCU)
- Statical linking (thanks to Gianpaolo Avallone (GPA)
- Some bugfixes and enhancements by Albert, Gianpaolo and others.
august 1, 2005 Release 2005.08.A
- UTF8 support to be set by property, solving a 'locale' problem.
- Bugfix for null strings
- Fix for static linking
- Solved bug in updatesql, fieldlist is now setup correctly
- solved bug in updatesql, inserting null values and constants.
august 2, 2005 Release 2005.08.B
- first steps towards support utf16 (by Kevin Zhang)
- implemented another locate routine (by jbannon)
- changed treatment of datatype text. It is considered 'longtext' now.
added 'shorttext' datatype which replaces the original 'text' datatype.
The datatype text is now compatible with sqlite3, mysql and perhaps
others.
sept 1, 2005 Release 2005.09.A
- code optimizations by Kevin Lu, Aducom
sept 1, 2005 Release 2005.09.B
- candidate fix for decimal point problem by Jordi March
sept 20, 2005 Release 2005.09.C
- implementation of unidirectional dataset. This improves
performance on large resultsets to the optimum. However
the dataset is readonly by default, using inserts/deletes and
updates will result in a 'database table is locked' error.
sept 21, 2005 Release 2005.09.D
- bugfix for decimal point routine by Kevin Lu
sept 29, 2005 Release 2005.09.E
- bugfix for unidirectional dataset.
- bugfix for split of prepare and execute. Data was not updated
correctly
nov 1, 2005 Release 2005.11.A
- Code improvements
- First (alpha) implementation of Lookup field (By John Lito)
dec 14, 2005 Release 2005.12.A
- Check for null values
jan 5, 2006 Release 2006.01.A
- fixed unidirectional bug (I)
jan 9, 2006 Release 2006.01.B
- fixed unidirectional bug (II)
- automatically will close table if tablename property is changed
while a table is still open.
- automatically close query if sql property is changed while a table
is still open.
- fixes for compilation under D4
- changes for installation under Delphi 2005 and 2006
- changes of copyright notice, the components are now under
open-source bsd licence.
feb 22, 2006 Release 2006.02.A
- Changed status to stable
mar 2, 2006 Release 2006.03.A
- Modifications for D4/D5
- Added order by property. Enter fieldnames separated by ','
- Added GetIndexFieldNames (thanks to zavu10n)
- Database will be reopened if necessary on filter change
- Fixes by Donnie
- New routine for dates and floates by Donnie
mar 8, 2006 Release 2006.03.B
- Fixed small bug causing text treated as char 255, is now memo.
mar 15, 2006 Release 2006.03.C
- Added switch for compilation under D4/D5 (Art Register)
- DBOpen change for utf8 by John Lito
- SQLCursor fix
- GetFieldValue fix by Velis
mar 23, 2006 Release 2006.03.D
- Compatibility fixes for D45 (Art Register)
- changed D45 directive to $IFDEF ASQLITE_D6PLUS so
compilation should work automatically now
- changed cr cr/lf pairs for compatibilty with D4/D5
- added CompareBookmarks to support multiple selection
in DBGrid (Michael S)
- added support for char *nothing* datatype (was char(1) now char is allowed)
mar 27,2006 Release 2006.03.E Beta
- Fixed master-detail bug
- Source optimizations (old source is still commented out, will
be deleted on stable release
- Date and Time type are now treated as is should have been
from the beginning. DateTime type is stored ansi way,
Date type is stored yyyy-mm-dd, Time type is stored hh:nn:ss.mmm
It's possible that next release will only use hh:nn:ss due
to problems with vcl components who do not support mmm.
mar 29,2006
- Fixed small bug causing the shortdateformat to be overwritten
apr 03,2006
- added support for getschemaversion (CoRSA)
Release 2006.09.A was based upon another source (ADO-based).
sept 14,2006 Release OldStyle 2006.09.B
- OK, Within the null support release it appeared that it
had a lot of obscure problems. This was costing me so much time
I decided to recover and implement another null support based
on the latest stable release (by Jure) and patched all the
updates from the forum. I also implemented the following patches:
- Kevin Lu: patch for utf8
- VSmolenski: patch for sql cursor
- Michael: patch for queryfilter
- Jure: NULL SUPPORT (tnx!!)
- Kwerling: patch for sqlite busy bug
- CoRSA: patch for retrieving temp. tables
nov 2, 2006 Release 2006.11.A
- Fix by Sean, adding 'required' field check
- Fix UTF8 by Coldak
- Adding BusyTimeOut by Sean
- Support for collation
feb 22, 2006 Release 2007.02.A
- Fix to solve Blob isue (generated AV)
- Added InTransactionFunction
- Fixes for collation (Jure)
- Fixes for Null Support (Jure) to solve DUnit isues
(by Sean)
- Null support for Blobs is not supported. Due to the
fact that a null value is kept with the field, the
Blob object is always created thus causing the field
to contain the blobpointer which is never null...
Try to fix that in some other version. There where some
code changes necessary to let the DUnit tests run through.
- Other (minor) isues.
*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
interface
uses
DB,
DBCommon,
Dialogs,
Classes,
Windows,
SysUtils,
SqlTimSt,
{$IFDEF ASQLITE_D6PLUS}
Variants,
{$ENDIF}
ASGRout3;
const
SQLiteVersion = 'ASGSQLite V2007.02.A beta';
MAX_FIELDS = 2048;
MaxBuf = 30000; // max stringbuffer for record (length) (excluding blob's)
SQLITE_OK = 0; // Successful result */
SQLITE_ERROR = 1; // SQL error or missing database */
SQLITE_INTERNAL = 2; // An internal logic error in SQLite */
SQLITE_PERM = 3; // Access permission denied */
SQLITE_ABORT = 4; // Callback routine requested an abort */
SQLITE_BUSY = 5; // The database file is locked */
SQLITE_LOCKED = 6; // A table in the database is locked */
SQLITE_NOMEM = 7; // A malloc() failed */
SQLITE_READONLY = 8; // Attempt to write a readonly database */
SQLITE_INTERRUPT = 9; // Operation terminated by sqlite_interrupt() */
SQLITE_IOERR = 10; // Some kind of disk I/O error occurred */
SQLITE_CORRUPT = 11; // The database disk image is malformed */
SQLITE_NOTFOUND = 12; // (Internal Only) Table or record not found */
SQLITE_FULL = 13; // Insertion failed because database is full */
SQLITE_CANTOPEN = 14; // Unable to open the database file */
SQLITE_PROTOCOL = 15; // Database lock protocol error */
SQLITE_EMPTY = 16; // (Internal Only) Database table is empty */
SQLITE_SCHEMA = 17; // The database schema changed */
SQLITE_TOOBIG = 18; // Too much data for one row of a table */
SQLITE_CONSTRAINT = 19; // Abort due to contraint violation */
SQLITE_MISMATCH = 20; // Data type mismatch */
SQLITE_MISUSE = 21; // Library used incorrectly */
SQLITE_NOLFS = 22; // Uses OS features not supported on host */
SQLITE_AUTH = 23; // Authorization denied */
SQLITE_ROW = 100; // sqlite_step() has another row ready */
SQLITE_DONE = 101; // sqlite_step() has finished executing */
SQLITE_CREATE_INDEX = 1; // Index Name Table Name */
SQLITE_CREATE_TABLE = 2; // Table Name NULL */
SQLITE_CREATE_TEMP_INDEX = 3; // Index Name Table Name */
SQLITE_CREATE_TEMP_TABLE = 4; // Table Name NULL */
SQLITE_CREATE_TEMP_TRIGGER = 5; // Trigger Name Table Name */
SQLITE_CREATE_TEMP_VIEW = 6; // View Name NULL */
SQLITE_CREATE_TRIGGER = 7; // Trigger Name Table Name */
SQLITE_CREATE_VIEW = 8; // View Name NULL */
SQLITE_DELETE = 9; // Table Name NULL */
SQLITE_DROP_INDEX = 10; // Index Name Table Name */
SQLITE_DROP_TABLE = 11; // Table Name NULL */
SQLITE_DROP_TEMP_INDEX = 12; // Index Name Table Name */
SQLITE_DROP_TEMP_TABLE = 13; // Table Name NULL */
SQLITE_DROP_TEMP_TRIGGER = 14; // Trigger Name Table Name */
SQLITE_DROP_TEMP_VIEW = 15; // View Name NULL */
SQLITE_DROP_TRIGGER = 16; // Trigger Name Table Name */
SQLITE_DROP_VIEW = 17; // View Name NULL */
SQLITE_INSERT = 18; // Table Name NULL */
SQLITE_PRAGMA = 19; // Pragma Name 1st arg or NULL */
SQLITE_READ = 20; // Table Name Column Name */
SQLITE_SELECT = 21; // NULL NULL */
SQLITE_TRANSACTION = 22; // NULL NULL */
SQLITE_UPDATE = 23; // Table Name Column Name */
SQLITE_ATTACH = 24; // Filename NULL */
SQLITE_DETACH = 25; // Database Name NULL */
SQLITE_DENY = 1; // Abort the SQL statement with an error */
SQLITE_IGNORE = 2; // Don't allow access, but don't generate an error */
Crlf : string = #13#10;
Q = '''';
type
pInteger = ^integer;
pPointer = ^Pointer;
pSmallInt = ^smallint;
pFloat = ^extended;
pBoolean = ^boolean;
TConvertBuffer = array[1..255] of char;
TSQLite3_Callback = function(UserData: Pointer; ColumnCount: Integer; ColumnValues, ColumnNames: PPointer): Integer; cdecl;
// TSQLiteExecCallback = function(Sender: TObject; Columns: integer; ColumnValues: Pointer; ColumnNames: Pointer): integer of object; cdecl;
TSQLiteBusyCallback = function(Sender: TObject; ObjectName: PAnsiChar; BusyCount: integer): integer of object; cdecl;
TOnData = procedure(Sender: TObject; Columns: integer; ColumnNames, ColumnValues: string) of object;
TOnBusy = procedure(Sender: TObject; ObjectName: string; BusyCount: integer; var Cancel: boolean) of object;
TOnQueryComplete = procedure(Sender: TObject) of object;
TASQLite3NotifyEvent = procedure(Sender: TObject) of object;
// structure for holding field information. It is used by GetTableInfo
TASQLite3Field = class
public
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?