当前位置:主页>仓库管理软件> 列表

关于百万级多从表角决方案心得 找家庭记账软件推荐

库存管理软件版1楼: 现在张三个表 me_ba
me_ba1
me_ba2
关系 me_ba.sid = me_ba1.mastersid
me_ba1.sid = me_ba2.mastersid
三张表加现来的记录过千万。
开发环境 win2003+delphi2006+dbexpree+clientdateset
数据库 sql2000
硬件 XEMO 2 2.8 2GRAM
并发操作 约100台计算机
没有解决之前打开数据表 本地网络2分钟以上
vpn网络20多分钟
问题点
返回的记录太多.Top N来解决问题.
解决要点1:如何用分页技术.
解决locate的问题.
解决删除更新问题
解决多表更新问题
经过一天的努力搞定...
{ ################################################################### }
{ ## ## }
{ ## ## ## ######## ## ## ## }
{ ## ## ## ## ## ## ## }
{ ## ## ## ## ## ## ## }
{ ## ## ## ########## ## }
{ ## ## ## ## ## ## ## }
{ ## ## ## ## ## ## ## }
{ ## ## ## ## ## ## }
{ ## ## }
{ ################################################################### }
unit YClientDatasetTable;

interface

uses
SysUtils, Classes, DB, DBClient,DBXpress, FMTBcd, Provider, SqlExpr,
Dialogs,Variants,Controls,Forms,SimpleDS,db_err;
const
Tsqlcount = '' Select count(*) as idcount from '' ;

type

EOnLoacte = procedure(Sender: TObject; var EditType :Boolean) of object;

TSortType = (stNone, stAscending, stDescending);

TYClientDatasetTable = class ;

TYSQLTable = Class ;

TYDataSetProvider = Class ;

TYClientDatasetTable = class(TClientDataSet)

private

FFieldCaptionID : Word ;
FSQLConnection: TSQLConnection;
FSQLTableName :String;
TempcommandText :String;
FNativeCommand,FDetailField: string;
FFieldCaptionIDName:String;
FOnLoacte: EOnLoacte;
FSYS_SelectOtherKeyIDCondition:String;

FIndexa,FDel,TempSetSqlEndRecno,TempSetSqlbeginRecno: Integer;
FProviderName:String;
FGetUserType,FGetIDNo,FGetuserdatetime,FTableNameUppercase,FISApplicationSelectTeam : Boolean ;
FOldOnReconcileError:TReconcileErrorEvent;
procedure LocateSQl(sqlid: String);
function GetSqlEndRecno: Integer;
procedure SetSqlEndRecno(const Value: Integer);
function GetSqlBeginRecno: Integer;
function GetSqlRecordCount: Integer;
procedure SetSqlBeginRecno(const Value: Integer);
procedure DoReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;
var Action: TReconcileAction);
procedure SetTableName(Value: string);

procedure ERR_SID;

procedure GetTablesId;
procedure GetCuserdatetime;
procedure GetEuserdatetime;
procedure SetSQLConnection(Value: TSQLConnection);

{ Private declarations }
protected
Looktype : boolean ;
procedure DoBeforeOpen; override;
procedure DoAfterOpen; override;
procedure DataEvent(Event: TDataEvent; Info: Longint); override;
procedure DoBeforeClose; override;
procedure Loaded; override;
procedure DoAfterDelete; override;
procedure DoOnNewRecord ; override;
procedure DoBeforeEdit ; override;
procedure DoBeforeCancel ; override;
procedure DoBeforePost ; override;
procedure DoAfterApplyUpdates(var OwnerData: OleVariant); override;
procedure InternalSort(Fields: string; SortType: TSortType;M:Boolean);

{ Protected declarations }
public
YDataSetProvider : TYDataSetProvider;
YSQLTable : TYSQLTable;
FFilter: string;
FFiltered: Boolean;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Locate(const KeyFields: string; const KeyValues: Variant;
Options: TLocateOptions): Boolean; override;
procedure sql_AfterScroll;
Procedure ReDown;
procedure SortByField(Fields: string;M:Boolean);
procedure SortDescByField(Fields: string;M:Boolean);
property SqlRecordCount: Integer read getSqlRecordCount ;
property SqlBeginRecno: Integer read GetSqlBeginRecno write SetSqlBeginRecno;
property SqlEndRecno: Integer read GetSqlEndRecno write SetSqlEndRecno;
{ Public declarations }
published
property SYS_SelectOtherKeyIDCondition: string read FSYS_SelectOtherKeyIDCondition write
FSYS_SelectOtherKeyIDCondition;
Property FieldCaptionID : Word Read FFieldCaptionID write FFieldCaptionID default 0;
property FieldCaptionIDName : String read FFieldCaptionIDName write FFieldCaptionIDName;
property GetIDNo : Boolean read FGetIDNo write FGetIDNo default False;
property GetUserType : Boolean read FGetUserType write FGetUserType default True;
property SQLConnection: TSQLConnection read FSQLConnection write SetSQLConnection;
property SQLTableName: string read FSQLTableName write SetTableName;
property Getuserdatetime :Boolean read FGetuserdatetime write FGetuserdatetime default True;
property DetailField: string read FDetailField write FDetailField;
property TableNameUppercase: Boolean read FTableNameUppercase write FTableNameUppercase default False;
property ISApplicationSelectTeam: Boolean read FISApplicationSelectTeam write FISApplicationSelectTeam default False;
property OnLoacte: EOnLoacte read FOnLoacte write FOnLoacte;
{ Published declarations }
end;

TYDataSetProvider = class(TDataSetProvider)
private
{ Private declarations }
protected
procedure Loaded; override;
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;

destructor Destroy; override;
{ Public declarations }
published
{ Published declarations }
end;



TYSQLTable = class(TSQLDataSet)
private
{ Private declarations }
protected
procedure DoBeforeOpen; override;
procedure DoAfterOpen; override;
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

{ Public declarations }
published
{ Published declarations }
end;

procedure Register;

implementation
uses umysystem,commvar,uPublic;
procedure Register;
begin
RegisterComponents(''DB Table'', [TYClientDatasetTable]);
end;

Procedure TYClientDatasetTable.ReDown;
var
cRecno:TBookmark;
begin
Self.Close;
YSQLTable.Close;
YSQLTable.Close;
Self.Open;
end;

procedure TYClientDatasetTable.SetSQLConnection(Value: TSQLConnection);
var
IsActive: Boolean;
begin
if Value <> FSQLConnection then
begin
IsActive := Active;
CheckInactive;
FSQLConnection := Value;
if Assigned(FSQLConnection) then
begin
Active := IsActive;
end;
end;
end;

procedure TYClientDatasetTable.SetSqlBeginRecno(const Value: Integer);
begin
if Value <> TempSetSqlbeginRecno then
begin
TempSetSqlbeginRecno := Value;
end;
end;

procedure TYClientDatasetTable.SetSqlEndRecno(const Value: Integer);
begin
if Value<> TempSetSqlEndRecno then
begin
TempSetSqlEndRecno := Value;
end;
end;


function TYClientDatasetTable.GetSqlBeginRecno: Integer;
begin
Result:= TempSetSqlbeginRecno;
end;

function TYClientDatasetTable.GetSqlEndRecno: Integer;
begin
Result := TempSetSqlendRecno;
end;

function TYClientDatasetTable.GetSqlRecordCount: Integer;
var
Y_Query :TSQLQuery;
begin
Y_Query := TSQlQuery.Create(Self);


Y_Query.SQLConnection := SQLConnection;
Y_Query.SQL.Add( Tsqlcount + sqltablename) ;
Y_Query.open;
Result:= Y_Query.FieldByName(''idcount'').AsInteger;
Y_query.Close;
Y_query.Free;
end;
procedure TYClientDatasetTable.SetTableName(Value: string);
begin
if FSQLTableName <> Value then
begin
FNativeCommand := '''';
FSQLTableName := Value;
end;
end;

destructor TYClientDatasetTable.Destroy;
begin
YSQLTable.Free ;
YDataSetProvider.Free ;
inherited Destroy;
end;

constructor TYClientDatasetTable.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FGetuserdatetime:=True;
OnReconcileError:=DoReconcileError;
YSQLTable:=TYSQLTable.Create(Self);
YSQLTable.GetMetadata := False;
//YSQLTable.Prepared:= False;
//YSQLTable.ParamCheck := False;
// YSQLTable.MaxBlobSize:= -1 ;
YDataSetProvider:=TYDataSetProvider.Create(Self);
//YDataSetProvider.ResolveToDataSet := true;
FTableNameUppercase:= False;
FISApplicationSelectTeam := False;
// Self.ProviderName:=YDataSetProvider.Name;
end;


procedure TYClientDatasetTable.DoBeforeOpen;
{const
coEnableBCD = TSQLConnectionOption(102); // boolean}
var

TT:String;
begin

if SQLConnection <> nil then
begin
Ysqltable.close ;
ysqltable.sqlconnection := tyclientdatasettable(self).sqlconnection;
{$IFDEF VER170}
// tyclientdatasettable(Self).SQLConnection.SQLConnection.SetOption(coEnableBCD, Integer(False));
{$ENDIF}

if self.CommandText ='''' then
begin
{ if State <> dsInactive then
T:= RecordCount else
T:= 0;}
{if not FTableNameUppercase then
Ysqltable.commandtext :=Uppercase(TYclientdatasettable(self).SqlTableName)
else
ysqltable.commandtext := Uppercase(tyclientdatasettable(self).sqltablename); }
// FSqlRecordCount := GetSqlRecordCount;
if (PacketRecords > 0) and (MasterSource = nil) then
begin
if pos(''top'',ysqltable.CommandText) = 0 then
begin
ysqltable.CommandText:= ''select top ''+ inttostr(PacketRecords) +'' * from '' +TYclientdatasettable(self).sqltablename ;
TempcommandText := ysqltable.CommandText;
end;
//SqlBeginRecno := 0;
// SqlendRecno := PacketRecords;
end else
begin
ysqltable.commandtype:= ctquery;
ysqltable.CommandText:= ''select * from '' +TYclientdatasettable(self).sqltablename;

if MasterSource <> nil then
begin
if pos(''where'',ysqltable.CommandText) = 0 then
begin
if pos('';'',IndexFieldNames) <> 0 then
Params.CreateParam(ftstring, copy(IndexFieldNames,1,pos('';'',IndexFieldNames)-1),ptinput)
else

Params.CreateParam(ftstring, IndexFieldNames,ptinput);
end;
end;
if SYS_Password then
ysqltable.CommandText:= ysqltable.CommandText+ '' '' + SYS_SelectOtherKeyIDCondition;
end;
end
else
begin
ysqltable.commandtype:= ctquery;
if PacketRecords > 0 then
begin
if pos(''top'',CommandText) = 0 then
begin
CommandText:= StringReplace(CommandText,''*'','' top 100 * '' ,[rfReplaceAll,rfIgnoreCase]);
TempcommandText := CommandText;
end;
end else
ysqltable.CommandText:= CommandText;
end;
Ydatasetprovider.dataset := ysqltable;
{$IFDEF VER150}
Ydatasetprovider.Options:=[poAllowCommandText];
{$ENDIF}
{$IFDEF VER170}
Ydatasetprovider.Options:=[poAllowCommandText,poUseQuoteChar,poFetchDetailsOnDemand];
{$ENDIF}
{$IFDEF VER180}
Ydatasetprovider.Options:=[poAllowCommandText,poUseQuoteChar,poFetchDetailsOnDemand];
{$ENDIF}

Ydatasetprovider.updatemode :=upWhereAll;
SetProvider(Ydatasetprovider);

inherited dobeforeopen;
end
else
inherited DoBeforeOpen;
end;

procedure TYClientDatasetTable.sql_AfterScroll;
begin
if not Looktype then begin
Looktype:= True;
exit;
end ;
if (RecNo = RecordCount) then {SqlBeginRecno }
begin {SqlendRecno}
if SqlendRecno < SqlRecordCount then //记录数大于
begin
close;
if self.CommandText<> '''' then
begin
if pos(''top'',CommandText) <> 0 then
begin
if pos(''where'',ysqltable.CommandText) = 0 then
CommandText:= CommandText + SWhere
+'' sid not in (select top ''+ inttostr(SqlBeginRecno + PacketRecords) + '' sid from ''
+TYclientdatasettable(self).sqltablename +'')''
else
CommandText:= TempcommandText +
SAnd +'' sid not in (select top ''+ inttostr(SqlBeginRecno + PacketRecords) + '' sid from ''+TYclientdatasettable(self).sqltablename +'')'';
end;
end else
begin
if pos(''top'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ''select top ''+ inttostr(PacketRecords) +'' * from '' +TYclientdatasettable(self).sqltablename ;
if pos(''where'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ysqltable.CommandText + SWhere +'' sid not in (select top ''+ inttostr(SqlBeginRecno + PacketRecords) + '' sid from ''+TYclientdatasettable(self).sqltablename +'')''
else
ysqltable.CommandText:= TempcommandText + SWhere +'' sid not in (select top ''+ inttostr(SqlBeginRecno + PacketRecords) + '' sid from ''+TYclientdatasettable(self).sqltablename+'')'';


end;
SqlBeginRecno := SqlBeginRecno+PacketRecords;
SqlendRecno := SqlBeginRecno+PacketRecords;
//sql语言
redown;
end;
end else
if RecNo = 1 then
begin
if SqlBeginRecno <> 0 then
begin
close;
if self.CommandText<> '''' then
begin
if pos(''top'',CommandText) <> 0 then
begin
if pos(''where'',ysqltable.CommandText) = 0 then
CommandText:= CommandText + SWhere +'' sid not in (select top ''+ inttostr(ABS(SqlBeginRecno - PacketRecords)) + '' sid from ''+TYclientdatasettable(self).sqltablename +'')''
else
CommandText:= TempcommandText + SAnd +'' sid not in (select top ''+ inttostr(ABS(SqlBeginRecno - PacketRecords)) + '' sid from ''+TYclientdatasettable(self).sqltablename+'')'';
end;
end else
begin
if pos(''top'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ''select top ''+ inttostr(PacketRecords) +'' * from '' +TYclientdatasettable(self).sqltablename ;
if pos(''where'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ysqltable.CommandText + SWhere +'' sid not in (select top ''+ inttostr(ABS(SqlBeginRecno - PacketRecords)) + '' sid from ''+TYclientdatasettable(self).sqltablename+'')''
else
ysqltable.CommandText:= TempcommandText + SWhere +'' sid not in (select top ''+ inttostr(ABS(SqlBeginRecno - PacketRecords)) + '' sid from ''+TYclientdatasettable(self).sqltablename+'')'';
end;
SqlBeginRecno := SqlBeginRecno-PacketRecords;
SqlendRecno := SqlBeginRecno-PacketRecords;
redown;
end;
end;
Looktype:= True;

end;



procedure TYClientDatasetTable.LocateSQl(sqlid:String);
begin

close;
if self.CommandText<> '''' then
begin

if pos(''top'',CommandText) <> 0 then
begin
if pos(''where'',ysqltable.CommandText) = 0 then
CommandText:= CommandText + SWhere
+'' sid not in (select top ''+ inttostr(0) + '' sid from ''
+TYclientdatasettable(self).sqltablename +'' ) '' + SAnd + sqlid
else
CommandText:= TempcommandText +
SAnd +'' sid not in (select top ''+ inttostr(0) + '' sid from ''+TYclientdatasettable(self).sqltablename +'' ) '' + SAnd + sqlid ;
end;
end else
begin
if pos(''top'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ''select top ''+ inttostr(PacketRecords)
+'' * from ''
+TYclientdatasettable(self).sqltablename + SAnd +sqlid ;
if pos(''where'',ysqltable.CommandText) = 0 then
ysqltable.CommandText:= ysqltable.CommandText
+ SWhere +'' sid not in (select top ''+ inttostr(0)
+ '' sid from ''+TYclientdatasettable(self).sqltablename +'') ''+ SAnd + sqlid
else
ysqltable.CommandText:= TempcommandText + SWhere
+'' sid not in (select top ''+ inttostr(0) + '' sid from ''
+TYclientdatasettable(self).sqltablename+'') '' + SAnd +sqlid ;
end;
SqlBeginRecno := SqlBeginRecno+PacketRecords;
SqlendRecno := SqlBeginRecno+PacketRecords;
Looktype := False;
//sql语言
redown;

end;


procedure TYClientDatasetTable.DoAfterOpen;
var
i:integer;
begin
if Trim(DetailField)<> '''' then
begin
if FIndexa=0 then
FIndexa:= RecordCount;
FDel:= 0;
end;
for i:=0 to FieldCount-1 do
begin
if self.Fields[i].DataType in [ftFloat, ftCurrency, ftBCD] then
if (Uppercase(Self.Fields[i].FieldName) <> ''LINENO'') or (Uppercase(Self.Fields[i].FieldName) <> ''VLINENO'') then
Tnumericfield(Self.Fields[i]).DisplayFormat := Reprot_Numeric;
end;

inherited DoAfterOpen;
end;

procedure TYClientDatasetTable.DataEvent(Event: TDataEvent; Info: Integer);
begin
inherited;
{if (PacketRecords > 1 ) and ( MasterSource = nil ) then
case Event of
deDataSetScroll: sql_AfterScroll;
end; }
end;

procedure TYClientDatasetTable.GettablesId;

begin

END;

procedure TYClientDatasetTable.GetCuserdatetime;
begin
end;
procedure TYClientDatasetTable.GetEuserdatetime;
begin
end;



procedure TYClientDatasetTable.DoAfterDelete;
begin
Inherited DoAfterDelete;
if DBkeyButtonDeleteTheTran then exit;
{if Trim(DetailField)= '''' then Exit;
DisableControls;
cRecno:=Getbookmark;
g:=0 ;
First;
While NOT EOF DO
BEGIN
g:=G+1;
edit;
FieldByName(DetailField).AsInteger:=g;
NEXT;
END;
if cRecno<>nil then
GotoBookmark(cRecNo);
FreeBookmark(cRecNo);


EnableControls;

{ if Trim(DetailField)= '''' then Exit;
DisableControls;
While NOT EOF DO
BEGIN
Edit;
FieldByName(DetailField).AsInteger:=FieldByName(DetailField).AsInteger-1 ;
NEXT;
END;
EnableControls;}
end;

procedure TYClientDatasetTable.DoOnNewRecord;
begin

Inherited DoOnNewRecord;
if GetIDNo then
GettablesId;
if Getuserdatetime then
GetCuserdatetime;
if Trim(DetailField)<> '''' then
begin
//if FieldByName(DetailField).AsInteger =0 then
if RecordCount=0 then
FIndexa:= 0;
if FIndexa < (RecordCount+1) then
begin
FIndexa:= RecordCount+1;
end;
if FIndexa = (RecordCount+1) then
begin
if RecordCount <> 0 then
begin
FieldByName(DetailField).AsInteger:= FIndexa;
FIndexa:= FIndexa+1;
end
else
begin
FieldByName(DetailField).AsInteger:= FIndexa;
FIndexa:= 1;
end;
end
else
begin
FieldByName(DetailField).AsInteger:=FIndexa+1;
FIndexa:=FIndexa+1;
end;
{else
FieldByName(DetailField).AsInteger:=(FieldByName(DetailField).AsInteger)+1;}
end;

end;

procedure TYClientDatasetTable.DoBeforeEdit ;
begin
if Trim(DetailField)<> '''' then
begin
if FIndexa=0 then
FIndexa:= RecordCount;
end;
Inherited DoBeforeEdit;
end;
procedure TYClientDatasetTable.DoBeforeCancel ;
begin
if FIndexa < (RecordCount+1) then
begin
FIndexa:= RecordCount+1;
end;
if FIndexa <> (RecordCount+1) then
FIndexa:=FIndexa-1;
Inherited DoBeforeCancel;
end;



procedure TYClientDatasetTable.DoBeforePost ;
begin
if Getuserdatetime then
GetEuserdatetime;


if Trim(DetailField)<> '''' then
BEGIN
IF FieldByName(DetailField).AsInteger > FIndexa THEN
begin
FIndexa:= FieldByName(DetailField).AsInteger;
end
else
begin
if RecNo=RecordCount then
if FIndexa = (RecordCount+1) then
FIndexa:= FieldByName(DetailField).AsInteger+1
else
FIndexa:= FieldByName(DetailField).AsInteger;
end;
END;
Inherited DoBeforePost;
end;



procedure TYClientDatasetTable.DoAfterApplyUpdates;
begin
FIndexa := 0 ;
inherited DoAfterApplyUpdates(OwnerData);
end;
procedure TYClientDatasetTable.Loaded;
var
TempReconcileError:TReconcileErrorEvent;
begin
if not (csDesigning in ComponentState) then
begin
if @OnReconcileError <> @TempReconcileError then
FOldOnReconcileError:=OnReconcileError
else
FOldOnReconcileError:=nil;
end;
//FTableNameUppercase:= True;
{ if SqlTableName <> '''' then
FileName:= SqlTableName+''.cds''
else
FileName:= self.Name+''.cds'';}
inherited Loaded;
end;



{ Inc records sort by a field }
procedure TYClientDatasetTable.SortByField(Fields: string;M:Boolean);
begin
try
InternalSort(Fields, stAscending,M);
except

end;

end;

{ Descending records sort by field }
procedure TYClientDatasetTable.SortDescByField(Fields: string;M:Boolean);
begin
try
InternalSort(Fields, stDescending,M);
except

end;
end;

{ Clear records sort order }


procedure TYClientDatasetTable.InternalSort(Fields: string; SortType: TSortType;M:Boolean);
var

OldCursor: TCursor;
VarFields :String;
OldIndexFieldNames:String;
begin
VarFields:=Fields;
OldCursor := Screen.Cursor;
try
Screen.Cursor := crSqlWait;
if SortType in [stDescending] then
begin
if M then// 不清除
begin
if pos(Self.IndexFieldNames,trim(varFields))=0 then


Self.IndexFieldNames:=Self.IndexFieldNames+'';''+trim(varFields)
end
else
begin
OldIndexFieldNames:=copy(Self.IndexFieldNames,1,pos(Self.IndexFieldNames,'';''));
if OldIndexFieldNames='''' then
OldIndexFieldNames:=copy(Self.IndexFieldNames,1,Length(Self.IndexFieldNames));
if OldIndexFieldNames<>'''' then
begin
if Length(OldIndexFieldNames + trim(varFields)) < 125 then
Self.IndexFieldNames:=OldIndexFieldNames+'';''+trim(varFields)
end
else
begin
if self.MasterSource <> nil then
if pos( Self.IndexFieldNames,varFields) = 0 then
Self.IndexFieldNames:=trim(''mastersid'')+'';''+trim(varFields)
else
if pos( Self.IndexFieldNames,varFields) = 0 then
Self.IndexFieldNames:=trim(varFields)
end;
end;
end
else
begin
if M then// 不清除
begin
if pos(Self.IndexFieldNames,trim(varFields))=0 then
Self.IndexFieldNames:=Self.IndexFieldNames+'';''+trim(varFields)
end
else
begin
OldIndexFieldNames:=copy(Self.IndexFieldNames,1,pos(Self.IndexFieldNames,'';''));
if OldIndexFieldNames='''' then
OldIndexFieldNames:=copy(Self.IndexFieldNames,1,Length(Self.IndexFieldNames));
if OldIndexFieldNames <>'''' then
begin
if Length(OldIndexFieldNames + trim(varFields)) < 125 then
Self.IndexFieldNames:=OldIndexFieldNames+'';''+trim(varFields)
end
else
begin
if self.MasterSource <> nil then
if pos( Self.IndexFieldNames,varFields) = 0 then
Self.IndexFieldNames:=trim(''mastersid'')+'';''+trim(varFields)
else
if pos( Self.IndexFieldNames,varFields) = 0 then
Self.IndexFieldNames:=trim(varFields)
end;
end;
end;
finally
Screen.Cursor := OldCursor;
end;
end;



procedure TYClientDatasetTable.DoBeforeClose;

begin
if SQLConnection <> nil then
begin
YSQLTable.Close;
YSQLTable.CloseCursor;
YSQLTable.SQLConnection.CloseDataSets;
// commandText:= TempcommandText;
{if self.SQLConnection <> nil then
YSQLTable.SQLConnection.CloseDataSets;}
{ CloseCursor;
EmptyDataSet;}
end;
inherited DoBeforeClose;
end;

procedure TYClientDatasetTable.DoReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind;


var Action: TReconcileAction);
var
Msg,NameStr,UpdateStr:String;
begin
ERR_SID;

//ReconcileErrorMsg:=E.Message;
{if Assigned(FOldOnReconcileError) then
begin
FOldOnReconcileError(DataSet,E,UpdateKind,Action);
Exit;
end;
// HandleReconcileError(DataSet,UpdateKind,E);
if ((not Assigned(OnPostError))) then
begin
NameStr:=SqlTableName;
if NameStr = '''' then
NameStr:=Name;
case StrtoInt(GetLanguageID) of
1:
begin
case UpdateKind of
ukModify:UpdateStr:=''修改'';
ukInsert:UpdateStr:=''插入'';
ukDelete:UpdateStr:=''删除'';
end;
Msg:=''由于''+UpdateStr+''[''+NameStr+'']''+''错误,整个操作可能会被被取消!确切原因请看下一画面!请关闭单据画面重新进入以确认!'';
end;
2:
begin
case UpdateKind of
ukModify:UpdateStr:=''?э'';
ukInsert:UpdateStr:=''础?'';
ukDelete:UpdateStr:=''?埃'';
end;
Msg:=''パ?''+UpdateStr+''[''+NameStr+'']''+''岿粇,俱?巨???穦砆砆??!谔ち??叫???礶?!叫闽超虫誹礶??穝秈??谔粄!'';
end;

3:
begin
case UpdateKind of
ukModify:UpdateStr:=''Modify '';
ukInsert:UpdateStr:=''Insert '';
ukDelete:UpdateStr:=''Delete '';
end;
Msg:=''Because of ''+UpdateStr+''[''+NameStr+'']''+'' error,all operations may be rollbacked!See next picture for detail.Please close the form and reenter to check!'';
end;
end;
MessageDlg(Msg, mtWarning , [mbOK], 0);
end; }
redown;
end;

procedure TYClientDatasetTable.ERR_SID;
var
YSID_Query :TSQLQuery;
begin
YSID_Query:=TSQLQuery.Create(Self);
YSID_Query.sqlconnection := tyclientdatasettable(self).sqlconnection;
YSID_Query.SQL. add('' if ((select convert(int,(max(right(sid,len(sid)-2)))) from ''+ SQLTableName+'')'' );
YSID_Query.SQL.add('' > (select datanamenum from mrecno where dataname= ''+''''''''+SQLTableName+''''''))'');
YSID_Query.SQL.add(''update mrecno set datanamenum = '');
YSID_Query.SQL.add(''(select convert(int,(max(right(sid,len(sid)-2)))) '');
YSID_Query.SQL.add('' from ''+ SQLTableName + '' )where dataname=''+''''''''+SQLTableName+'''''' '');
YSID_Query.ExecSQL();
YSID_Query.Close;
YSID_Query.Free;
end;


{TYSQLTable ;}
constructor TYSQLTable.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// NumericMapping:= True;
end;

procedure TYSQLTable.DoBeforeOpen;
begin
inherited DoBeforeOpen;
end;

procedure TYSQLTable.DoAfterOpen;
var
i:Integer;
begin
inherited DoAfterOpen;
{ for i:=0 to FieldCount-1 do
begin
if self.Fields[i].FieldName=''sid'' then
Self.Fields[i].Required:= True;
end; }
end;
destructor TYSQLTable.Destroy;


begin
inherited Destroy;
end;

{TYDataSetProvider ;}
constructor TYDataSetProvider.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
SetName(Self.ClassName+IntToStr(Aowner.componentcount));
end;

procedure TYDataSetProvider.Loaded;
begin
inherited Loaded;
end;

destructor TYDataSetProvider.Destroy;
begin
inherited Destroy;
end;


function TYClientDatasetTable.Locate(const KeyFields: string; const KeyValues: Variant;
Options: TLocateOptions): Boolean;
var Yedittype :Boolean ;
begin
try
Yedittype:= True;
if (PacketRecords > 1) and (MasterSource = nil) then
LocateSQl('' '' +KeyFields +'' >= ''+ ''''''''+KeyValues+'''''''' + '' order by '' + KeyFields ) ;
if Assigned(FOnLoacte) then FOnLoacte(Self,Yedittype);
if YeditType then
Result:=Inherited Locate(KeyFields,KeyValues,Options)
else Result:= True;
except

end;
end;




end.

2楼: 学习 如家庭记账软件推荐

3楼: 瑕佹敹钘忎簡

4楼: 打击你一下:
我做的条形码管理系统,数据库记录主从表,主表30万条,从表3000万条,
而且每天以3万条的速度增加,每次保存和查询不能超过2秒。

5楼: 楼上的兄弟更牛,PFPF
贴出来大家看看、让大家学习学习

6楼: to dcsdcs,
小弟也要学习学习.....把代码贴出来

库存管理软件版7楼: 天啊,100台并发用户的系统还要动不动将所有数据返回客户端,我看不是用户疯了就是
开发的人疯了

8楼: 哈哈~~
这是很多开发人员的相同的地方~

9楼: TO;mark_yjh
能不能发给我一份例子,我有些地方我看不懂,高分求帮....

10楼: mark_yjh:第一保证服务器的速度,
采用IBM服务器,
服务器上保证最快。
基本该关的服务全部关闭,
软件采用存储过程,采用3层,而且连接池,导致数据库连接不超过10个。
绝对不会返回全部数据,最多返回100条数据。

11楼: 牛人啊