
10.04.2009, 09:58
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Я вам подкину примерчик небольшой, может он вам пригодиться:
Скомпилите и запустите несколько копий получившейся программы, вводите данные, должна работать синхронизация.
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, DBCtrls, DB, Grids, DBGrids, ADODB, StdCtrls;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
tDemo: TADOTable;
DBGrid1: TDBGrid;
dsDemo: TDataSource;
DBNavigator1: TDBNavigator;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
AdoConnection1.Open;
if not AdoConnection1.Connected
then begin
ShowMessage('Не подключились :(');
Exit;
end;
tDemo.Open;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
Var CurPos: Integer;
begin
if tDemo.State in [dsEdit,dsInsert] then Exit;
CurPos := tDemo.RecNo;
tDemo.Requery([eoAsyncFetch]);
tDemo.RecNo := CurPos;
end;
end.
Код:
object Form1: TForm1
Left = 286
Top = 199
Width = 642
Height = 410
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
DesignSize = (
634
376)
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 8
Top = 8
Width = 619
Height = 322
Anchors = [akLeft, akTop, akRight, akBottom]
DataSource = dsDemo
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object DBNavigator1: TDBNavigator
Left = 8
Top = 338
Width = 240
Height = 25
DataSource = dsDemo
Anchors = [akLeft, akBottom]
TabOrder = 1
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Se' +
'ttings\Администратор\Мои документы\demo.mdb;Mode=Share Deny None' +
';Persist Security Info=False'
CursorLocation = clUseServer
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 496
Top = 8
end
object tDemo: TADOTable
Connection = ADOConnection1
CursorLocation = clUseServer
CursorType = ctStatic
TableName = 'Table1'
Left = 528
Top = 8
end
object dsDemo: TDataSource
DataSet = tDemo
Left = 560
Top = 8
end
object Timer1: TTimer
Interval = 500
OnTimer = Timer1Timer
Left = 600
Top = 8
end
end
А по поводу получения IP, вот хороший примерчик
__________________
Жизнь такова какова она есть и больше никакова.
Помогаю за спасибо.
|