大概就是这样做法:
发送数据给服务器
Data := TStringList.Create;
try
table1.First;
while not Table1.Eof do
begin
if Table1CompID.IsNull or (Table1CompId.AsInteger = 0) then
begin
Data.Clear;
for I := 0 to Table1.FieldCount - 1 do
Data.Values [Table1.Fields.FieldName] :=
Table1.Fields .AsString;
ClientSocket1.Socket.SendText (Data.Text);
fWaiting := True;
while fWaiting do
Application.ProcessMessages;
end;
Table1.Next;
end;
finally
Data.Free;
ClientSocket1.Active := False;
end;
接收客户端的数据给数据集
Data := TStringList.Create;
try
Data.Text := strCommand;
Table1.Insert;
for I := 0 to Table1.FieldCount - 1 do
Table1.Fields .AsString :=
Data.Values [Table1.Fields.FieldName];
Table1CompID.AsInteger := GetTickCount;
Table1LoggedBy.AsString := Socket.RemoteAddress;
Table1LoggetOn.AsDateTime := Date;
Table1.Post;
strFeedback := Table1CompID.AsString;
Socket.SendText (strFeedback);
finally
Data.Free;
end;