Delphi 的数据库功能 很是强大。但是笔者使用中却面临着很多问题。其次开发一个小型数据库工程,也因为使用BDE 增加了文件的大小,和发布的难度。在笔者的使用途中发现了TStringList,的许多优点,下文通过TStringList 制作了一个简单的数据库,它不需要安装任何数据引擎,就可以工作:
unit UnitTextData;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TTextData = Class(TPersistent)
private
{ Private declarations }
FBase: TStringList;
FPath: String;
FtmpStr: TStringList;
FFieldNames: TStringList;
FPoint: Integer;
FFReSult: array of Integer;
FFPoint: Integer;
function GetFieldValue(FieldName: String): String;
procedure SetFieldValue(FieldName: String;
Value: String);
procedure GetFieldNames;
function IsBof: Boolean;
function IsEof: Boolean;
function FRecCount: Integer;
function GetFindCount: Integer;
function GetCurRecord: PString;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(FileName: String);
destructor Destroy; override;
procedure First;
procedure Last;
procedure Previous;
procedure Next;
function FindNo(No: Integer): Boolean;
property FieldValues[FieldName: String]: String
read GetFieldValue write SetFieldValue;
procedure InsertRec(Index: Integer);
procedure AppendRec;
procedure DeleteRec(Index: Integer);
function FindRec(Field: String;