⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asgsqlite3.pas

📁 连接sqlite数据库控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
(*

  //新增修改 by lck qq: 7896615
  由于这个控件较老没更新了,谁能搞到最新的,请通知到2ccc.com
  请尽量使用 最新sqlite版本的dll

  请高手帮助 让delphi使用 obj文件中的 sqlite3_key , 我不知道怎么修改
  
  静态引用obj 的编译指令:
  SQLite_Static
  
  2008.10 3.2.x中的 sqlite3_open 为ansi ,新版都为 utf8

  2008.9  3.5.9的 TableExistsCallback 返回 1 (abort) 对应 error 不太一样了

  2008.9  新版中的text 字段为 utf8,需要跟delphi的string作转换

  2008.8  加密调用 sqlite3_key  sqlite3_rekey
          加密property 为:  Databases (注意不是 Database)
          你可以用官方的非加密dll, 因为有assigned(sqlite3_rekey)判断


*)
// To enable debugging remove the dot. Do NOT forget to re-insert before
// deploying to production since this feature will slow down this component
// significantly
{.$DEFINE DEBUG_ENABLED } // Enables Debug information
 {.$DEFINE DEBUG_VERY_LOUD}
 {.$DEFINE DEBUG_LOUD}

// Disables IProvider interface for D4
{$DEFINE IPROVIDER}

// enable this if you want to link the SQLite library statically. (No need for dll)
//{$DEFINE SQLite_Static}

{$I asqlite_def.inc}

unit ASGSQLite3;
{*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Author:       Albert Drent
Description:  SQLite 3 DataSet class (encapsulates the Delphi DataSet Class)
              based upon the asqlite version for sqlite 2
Target:       Delphi 4, 5, 6 and 7; Delphi 2005; Borland C++ 5 and 6
Creation:     November 2003
Version:      2005.09.C Candidate Beta
EMail:        a.drent@aducom.com (www.aducom.com/sqlite, sqlite.aducom.com)
Support:      support@aducom.com (supportforum on www.aducom.com)
Legal issues: Copyright (C) 2003..2006 by Aducom Software

              Aducom Software
              Eckhartstr 61
              9746 BN  Groningen
              Netherlands

              Open Source licence (BSD: http://www.opensource.org/licenses/bsd-license.php)

              Copyright (c) 2006, Aducom Software
              All rights reserved.

              Redistribution and use in source and binary forms, with or without modification,
              are permitted provided that the following conditions are met:

              Redistributions of source code must retain the above copyright notice,
              this list of conditions and the following disclaimer.
              Redistributions in binary form must reproduce the above copyright notice,
              this list of conditions and the following disclaimer in the documentation
              and/or other materials provided with the distribution.
              Neither the name of Aducom Software nor the names of its contributors
              may be used to endorse or promote products derived from this software
              without specific prior written permission.
              THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
              "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
              TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
              PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
              COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
              INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
              DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
              GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
              HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
              STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
              IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
              POSSIBILITY OF SUCH DAMAGE.


Acknowledgement
              These components were written for our own needs. Since SQLite is
              a freeware component we like to donate this one to the community
              too. Parts of the code is adapted from several sources, but mainly
              from a sample and the vcl sources of Borland itself. And, of
              course, we did a lot and still are...
To Do
              A lot...
              We are very busy, but will develop on our needs. If anyone can
              contribute, please feel welcome. Alter the source with lots of comment
              and mail it to me. If it works right I will add it to the official
              source and add your credit here below. Before you start, please
              put a request on the forum. It would be a shame and a waste of your
              time if you develop something which already is...
History:
              Nov 8, 2003 First alpha release 1.0.A Albert Drent (c) 2003 Aducom Software
              Nov 11, Release alpha 1.0.B Albert Drent (c) 2003 Aducom Software
                        - added 'param' support
                        - fixed null pointer assignment
                        - added support for partial select (limit / offset)
              Nov 12, Release alpha 1.0.C Albert Drent (c) 2003 Aducom Software
                        - fixed bug in update
                        - support for events
                        - added 'RowsAffected'
              Nov 16, Release beta 1.0.D Albert Drent (c) 2003 Aducom Software
                        - fixed 0 resultlist after any ExecSQL usage
                        - added Transaction support
              Nov 24, Release beta 1.0.E Albert Drent (c) 2003 Aducom Software
                        - StartTransaction will open database if it is'nt already open
                        - Changed resultset method
                        - Added property editor for table names
                        - Added GetTableNames function to TASQLite3Database
                        - Added GetIndexNames function to TASQLite3Database
                        - Added Open and Close function to TASQLite3Database
                        - Added AutoCommit property to TDataSet descendants
                        - Split of source in designtime and runtime package
              Dec 15, Release beta 1.0.F Albert Drent (c) 2003 Aducom Software
                        - Optimized code for speed
                        - Added support for quering databases
                        - Added property for base directory (default dir) TDatabase
                        - Preparations for mastersets and TUpdateSQL (not functional yet)
                        - Solved GPF on stringfields
                        - Solved hangup of Delphi when developing
                        - Solved invalid pointer operation bug while developing
              Jan 11 2004, Release beta 1.0.G Albert Drent (c) 2003, 2004 Aducom Software
                        - Fixed GetTableNames Bug as reported on forum
                        - Solved some minor bugs, several code optimizations
                        - Added 'getfieldnames' procedure to asqlitedb
                        - Added component asqlitepragma for adjustments to sqlite behaviour
                        - Added several property editors to smooth things up
                        - Added component asqliteupdatesql
                        - Added master-detail support for TASQLite3table (not fully tested yet)
                        - Added master-detail support for TASQLite3query (not fully tested yet)
                        - Added filter property to TASQLite3Query
              Jan 18, 2004, Release beta 1.0.H Albert Drent (c) 2003, 2004 Aducom Software
                        - Added TASQLite3Log component
                        - Support for autoincrement (index primary key)
              Jan 22, 2004, Release beta 1.0.I Albert Drent (c) 2003, 2004 Aducom Software
                        - Solved bug, causing the user to open database first (where
                          it should be opened automatically after open query or table.
                        - datatype text is now treated as a string of max 255 chars.
                        - added samples
                        - added preparations for import and export component
              Jan 26, 2004, Release beta 1.1.A Albert Drent (c) 2003, 2004 Aducom Software
                        - Support for master-detail
                        - Support for TUpdateSQL
              Feb 05, 2004, Release beta 1.1.B Albert Drent (c) 2003, 2004 Aducom Software
                        - Solved small bug: basequery is closed on querychanged event
                        - Solved small bug: basequery is closed on filter change event
                        - Solved bug in design package, by Marc Wetzel(forum)
                        - Notification of BaseQuery removed and added to SQLiteTable
              Feb 24, 2004 Release alpha 1.2.A Albert Drent (c) 2003, 2004 Aducom Software
                        - Locate implemented, working on resultset!
                        - Some small bugfixes
              Feb 25, 2004 Release alpha 1.2.B Albert Drent (c) 2003, 2004 Aducom Software
                        - Reformat of source (Marc Wetzel)
                        - All the debug directives (Marc Wetzel)
                          The debug stuff is added to be able to do more debugging on the
                          components. At this stage there are still some isues which are
                          hard to be find.
                        - Some small bugfixes (Marc Wetzel)
                        - Solved bug with dblookupcombobox, lookup is now shown (variant error)
                        - Derived more classes from TDataset to solve compatibility isues with
                          3rd party software (DevExpress)
                        - Start of port to lower Delphi versions (designintf vs dsgnintf)
              March 25, 2004 Release alpha 1.2.C Albert Drent (c) 2003, 2004 Aducom Software
                        - Added property editor for database directory
                        - Added property editor for sqlitedll directory
                        - Bugix needed for release 13 of SQLite.dll (is compatible to lower
                          dll versions)
                        - More changes to solve compatibility problem with DevExpress (Plato of DevExpress)
                        - Solved some compatibility isues with TDataSet
                        - Solved some compatibility isues with the newest SQLite version (2.8.12)
                        - Added/modified, GetFieldNames, GetPrimaryKeys
                        - Added GetTableInfo
                        - Added StartTransaction and Commit and RollBack to TTable and TQuery
                          This will create a more readable source:
                             db.starttranaction;
                             q.somesql
                             db.commit
                          becomes now
                             with q do begin
                               starttransaction;
                               somesql;
                               try
                                 commit;
                               except
                                 rollback;
                               end;
                             end;
                        - Changed cleanup of components in notification (TheSneak)
                        - Fixed potential AV (so far not reported)
                        - Changed escape of string characters (TheSneak)
                          (might cause incompatibility of older components if you use single
                          quote in data)
                        - Fixed question mark problem in data (TheSneak)
              April 7, 2004
                        - Fixed bug GetxxxxNames, moved pragma (reported by Martini)
                        - Improved some performance isues (TheSneak)
                        - Added GetTableIndexNames(by Martini)
                        - Added support for 'small text blobs', it isn't the real stuff but
                          limited to 20000 characters.
                        - Fixed another compatibility isue with DevExpress
              April 8, 2004
                        - Fixed EnableControls (TheSneak)
                        - Fixed memoryleak ASQLiteQuery.InternalPost (TheSneak)
                        - Downgraded some stuff for support Delphi 4/5
                        - Updated Locate function (by Joel  hottcha@juno.com)
              April 14, 2004 Release beta 1.2.C Albert Drent (c) 2003, 2004 Aducom Software
                        - RawSQL property implemented (supresses parsing of sql data)
                        - published csv release as 1.2.C beta
              April 15, 2004 Release alpha 2.0.A Albert Drent (c) 2003, 2004 Aducom Software
                        - support for real clobs
                        - added fieldtype numeric(x.y)
                        - Implement RawSQL property in TASQLite3Query
              May 26, 2004 Release beta 2.0.B Albert Drent (c) 2003, 2004 Aducom Software
                        - new procedure: GetGetLastInsertRow
                        - new component: TASQLite3InlineSQL, to be used to contain all
                          kinds of pre-stored sql statements. I.e. for creation of tables in case
                          of an in-memory database, or a local storage for sql statements to
                          simplify sourcecode. In this release it is bound to the ASQLiteDB component.
                        - new component TASQLite3Output, to be used to generate csv files,
                          xml and html documents. It is NOT bound to ASQLite components but
                          to a datasource (containing any database connection)
                        - implemented bound as described by minhl on the forum
                        - implemented IsNull as described by Kazooie64 on the forum
                        - implemented a uniform datetime implementation by jpierce
              May, 26, 2004 Release beta 2.0.B Albert Drent (c) 2003, 2004 Aducom Software
                        - A few bugfixes
              June, 15, 2004 Release beta 2.0.C Albert Drent (c) 2003, 2004 Aducom Software
                        - A few bugfixes, thanks to Tzvetan
              July 2004, Release 1.0 based upon source sqlite version 2 components
              Okt 11, 2004 Release beta 1.0.B Albert Drent (c) 2003, 2004 Aducom Software
                        - Callback routine for retieving data replaced by new
                          by sqlite prefered way.
                        - Some bugfixes
                        - Support for calculated fields
                        - Support for real blobs
              okt 14, 2004 Release beta 1.0.C Albert Drent (c) 2003, 2004 Aducom Software
                        - support for locate lo-partial key (thanks to Bob Mitchel)
                        - some bugfixes (thanks to Oleg Lembievskiy marked by OL)
                        - some other bugfixes and code cleanup
              okt 18, 2004
                        - re-introduced sqlite_version
                        - added transactiontype property(SQLite3 feature)
                        - added transaction procedures to db and basequery
                                StartDeferredTransaction;
                                StartImmediateTransaction;
                                StartExclusiveTransaction;
              nov 1, 2004
                        - bugfix (thanx to James) for null pointer assignment on null values
              nov 8, 2004
                        - fixed introduced bug in result preventing new records to appear
                          right in dbgrids.
              nov 17, 2004
                        - fixed small bug showing rubish on empty tables
              Nov 17, 2004 by Mike Dijkema
                        - filter bug  FPrepared := FPrepared + ' and ' + Filter adds ' and filterexpr' to the end of the sql statement
                          this created errors with 'order by' 'limit' 'union' 'having' etc..
                          filtering changed to that it works like the ADO components and union and other statements
                          now 'select a from b union select c from d' and 'select a from b order by c' works with a filter
                        - filter bug 'select a_where from b' removed
              jan 11, 2005 Release 2005.01.A Albert Drent (c) 2003 .. 2005 Aducom Software
                        - fixed bug causing fielddescription to be deleted incorrectly
                        - fixed bug causing errormessage on null values in integer fields
                        - added sqlcursor property
                        - modifications to support Delphi 2005
                        - implemented all transactiontypes

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -