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

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

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

constructor TBDEClientDataSet.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataSet := TBDEQuery.Create(nil);
FDataSet.Name := Self.Name ''''DataSet1'''';
Provider.DataSet := FDataSet;
SqlDBType := typeBDE;
FLocalParams := TParams.Create;
end;

destructor TBDEClientDataSet.Destroy;
begin
FreeAndNil(FLocalParams);
FDataSet.Close;
FreeAndNil(FDataSet);
inherited Destroy;
end;

procedure TBDEClientDataSet.GetFieldNames(List: TStrings);
var
Opened: Boolean;
begin
Opened := (Active = False);
try
if Opened then
Open;
inherited GetFieldNames(List);
finally
if Opened then Close;
end;
end;

function TBDEClientDataSet.GetCommandText: string;
begin
Result := FCommandText;
end;

function TBDEClientDataSet.GetDataSet: TDataSet;
begin
Result := FDataSet as TDataSet;
end;

procedure TBDEClientDataSet.CheckMasterSourceActive(MasterSource: TDataSource);
begin
if Assigned(MasterSource) and Assigned(MasterSource.DataSet) then
if not MasterSource.DataSet.Active then
DatabaseError(SMasterNotOpen);
end;

procedure TBDEClientDataSet.SetParamsFromSQL(const Value: string);
var
DataSet: TQuery;
TableName, TempQuery, Q: string;
List: TBDECDSParams;
I: Integer;
Field: TField;
begin
TableName := GetTableNameFromSQL(Value);
if TableName <> '''''''' then
begin
TempQuery := Value;
List := TBDECDSParams.Create(Self);
try
List.ParseSelect(TempQuery);
List.AssignValues(Params);
for I := 0 to List.Count - 1 do
List[I].ParamType := ptInput;
DataSet := TQuery.Create(nil);
try
DataSet.DatabaseName := FDataSet.DatabaseName;
Q := GetQuoteChar;
DataSet.SQL.Add(''''select * from '''' Q TableName Q '''' where 0 = 1''''); { do not localize }
try
DataSet.Open;
for I := 0 to List.Count - 1 do
begin
if List.FFieldName.Count > I then
begin
try
Field := DataSet.FieldByName(List.FFieldName[I]);
except
Field := nil;
end;
end else
Field := nil;
if Assigned(Field) then
begin
if Field.DataType <> ftString then
List[I].DataType := Field.DataType
else if TStringField(Field).FixedChar then
List[I].DataType := ftFixedChar
else
List[I].DataType := ftString;
end;
end;
except
// ignore all exceptions
end;
finally
DataSet.Free;
end;
finally
if List.Count > 0 then
Params.Assign(List);
List.Free;
end;
end;
end;

procedure TBDEClientDataSet.SetSQL(const Value: string);
begin
if Assigned(Provider.DataSet) then
begin
TQuery(Provider.DataSet).SQL.Clear;
if Value <> '''''''' then
TQuery(Provider.DataSet).SQL.Add(Value);
inherited SetCommandText(Value);
end else
DataBaseError(SNoDataProvider);
end;

procedure TBDEClientDataSet.Loaded;
begin
inherited Loaded;
if FStreamedActive then
begin
SetActive(True);
FStreamedActive := False;
end;
end;

function TBDEClientDataSet.GetMasterFields: string;
begin
Result := inherited MasterFields;
end;

procedure TBDEClientDataSet.SetMasterFields(const Value: string);
begin
inherited MasterFields := Value;
if Value <> '''''''' then
IndexFieldNames := Value;
FDataSet.FKeyFields := '''''''';
end;

procedure TBDEClientDataSet.SetCommandText(Value: String);
begin
inherited SetCommandText(Value);
FCommandText := Value;
if not (csLoading in ComponentState) then
begin
FDataSet.FKeyFields := '''''''';
IndexFieldNames := '''''''';
MasterFields := '''''''';
IndexName := '''''''';
IndexDefs.Clear;
Params.Clear;
if (csDesigning in ComponentState) and (Value <> '''''''') then
SetParamsFromSQL(Value);
end;
end;

function TBDEClientDataSet.GetConnection: TDatabase;
begin
Result := FDataBase;
end;

procedure TBDEClientDataSet.SetConnection(Value: TDataBase);
begin
if Value = FDatabase then exit;
CheckInactive;
if Assigned(Value) then
begin
if not (csLoading in ComponentState) and (Value.DatabaseName = '''''''') then
DatabaseError(SDatabaseNameMissing);
FDataSet.DatabaseName := Value.DatabaseName;
end else
FDataSet.DataBaseName := '''''''';
FDataBase := Value;
end;

function TBDEClientDataSet.GetQuoteChar: String;
begin

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