手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>delphi>列表

delphi7找不到TBDEClientDataSet控件的解决方案

来源:互联网 作者:西部数码 时间:2008-04-09
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

unit BDEClientDataSet;

interface

uses Windows, SysUtils, Variants, Classes, DB, DBCommon, Midas,
SqlTimSt, DBClient, DBLocal, Provider, DBTables;


type
{ TBDEQuery }

TBDEQuery = class(TQuery)
private
FKeyFields: string;
protected
function PSGetDefaultOrder: TIndexDef; override;
end;

{ TBDEClientDataSet }
TBDEClientDataSet = class(TCustomCachedDataSet)
private
FCommandText: string;
FCurrentCommand: string;
FDataSet: TBDEQuery;
FDatabase: TDataBase;
FLocalParams: TParams;
FStreamedActive: Boolean;
procedure CheckMasterSourceActive(MasterSource: TDataSource);
procedure SetDetailsActive(Value: Boolean);
function GetConnection: TDataBase;
function GetDataSet: TDataSet;
function GetMasterSource: TDataSource;
function GetMasterFields: string;
procedure SetConnection(Value: TDataBase);
procedure SetDataSource(Value: TDataSource);
procedure SetLocalParams;
procedure SetMasterFields(const Value: string);
procedure SetParamsFromSQL(const Value: string);
procedure SetSQL(const Value: string);
protected
function GetCommandText: String; override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetActive(Value: Boolean); override;
procedure SetCommandText(Value: string); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure CloneCursor(Source: TCustomClientDataSet; Reset: Boolean;
KeepSettings: Boolean = False); override;
procedure GetFieldNames(List: TStrings); override;
function GetQuoteChar: String;
property DataSet: TDataSet read GetDataSet;
published
property Active;
property CommandText: string read GetCommandText write SetCommandText;
property DBConnection: TDataBase read GetConnection write SetConnection;
property MasterFields read GetMasterFields write SetMasterFields;
property MasterSource: TDataSource read GetMasterSource write SetDataSource;
end;

procedure Register;

implementation

uses BDEConst, MidConst;

type

{ TBDECDSParams }

TBDECDSParams = class(TParams)
private
FFieldName: TStrings;
protected
procedure ParseSelect(SQL: string);
public
constructor Create(Owner: TPersistent);
Destructor Destroy; override;
end;

constructor TBDECDSParams.Create(Owner: TPersistent);
begin
inherited;
FFieldName := TStringList.Create;
end;

destructor TBDECDSParams.Destroy;
begin
FreeAndNil(FFieldName);
inherited;
end;

procedure TBDECDSParams.ParseSelect(SQL: string);
const
SSelect = ''''select'''';
var
FWhereFound: Boolean;
Start: PChar;
FName, Value: string;
SQLToken, CurSection, LastToken: TSQLToken;
Params: Integer;
begin
if Pos('''' '''' SSelect '''' '''', LowerCase(string(PChar(SQL) 8))) > 1 then Exit; // can''''t parse sub queries
Start := PChar(ParseSQL(PChar(SQL), True));
CurSection := stUnknown;
LastToken := stUnknown;
FWhereFound := False;
Params := 0;
repeat
repeat
SQLToken := NextSQLToken(Start, FName, CurSection);
if SQLToken in [stWhere] then
begin
FWhereFound := True;
LastToken := stWhere;
end else if SQLToken in [stTableName] then
begin
{ Check for owner qualified table name }
if Start^ = ''''.'''' then
NextSQLToken(Start, FName, CurSection);
end else
if (SQLToken = stValue) and (LastToken = stWhere) then
SQLToken := stFieldName;
if SQLToken in SQLSections then CurSection := SQLToken;
until SQLToken in [stFieldName, stEnd];
if FWhereFound and (SQLToken in [stFieldName]) then
repeat
SQLToken := NextSQLToken(Start, Value, CurSection);
if SQLToken in SQLSections then CurSection := SQLToken;
until SQLToken in [stEnd,stValue,stIsNull,stIsNotNull,stFieldName];
if Value=''''?'''' then
begin
FFieldName.Add(FName);
Inc(Params);
end;
until (Params = Count) or (SQLToken in [stEnd]);
end;

{ TBDEQuery }

function TBDEQuery.PSGetDefaultOrder: TIndexDef;
begin
if FKeyFields = '''''''' then
Result := inherited PSGetDefaultOrder
else
begin // detail table default order
Result := TIndexDef.Create(nil);
Result.Options := [ixUnique]; // keyfield is unique
Result.Name := StringReplace(FKeyFields, '''';'''', ''''_'''', [rfReplaceAll]);
Result.Fields := FKeyFields;
end;
end;

{ TBDEClientDataSet }

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!