Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 6 of 6 total |
#10228 cannot write unlock table incident |
Tue, Mar 3 2009 2:54 AM | Permanent Link |
Garey | delphi+dbisam(4.05)
two timer , 1 timer to process insert, another timer process query and delete, always pop #10228 Error msg. i paste the source code, pls help me,thanks. ===this is a testing Source code=============== unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DB, dbisamtb; type Tfrmtestdbisam = class(TForm) Timerinsert: TTimer; TimerQry: TTimer; DBISAMDatabase1: TDBISAMDatabase; procedure FormShow(Sender: TObject); procedure CreateTable; procedure TimerinsertTimer(Sender: TObject); procedure TimerQryTimer(Sender: TObject); private { Private declarations } public { Public declarations } end; TCEThread = class(TThread) protected procedure Execute; override; end; var frmtestdbisam: Tfrmtestdbisam; implementation {$R *.dfm} procedure Tfrmtestdbisam.CreateTable; var filepath: String; v_SQL: String; qryCretetbl: TDBISAMQuery; begin qryCretetbl := TDBISAMQuery.Create(nil); filepath := ExtractFilePath(Application.ExeName)+'cedb'; qryCretetbl.DatabaseName := filepath; v_sql := ' CREATE TABLE IF NOT EXISTS "INCIDENT" '+#10+ ' ( '+#10+ ' idx autoinc,'+#10+ ' receiveddate timestamp,'+#10+ ' atkdate Date,'+#10+ ' atktime time,'+#10+ ' sourceip varchar(15),'+#10+ ' sourcenum integer,'+#10+ ' sourcename varchar(50),'+#10+ ' sourceport varchar(10),'+#10+ ' targetip varchar(30),'+#10+ ' targetnum integer,'+#10+ ' targetname varchar(30),'+#10+ ' targetport varchar(30),'+#10+ ' attacktype varchar(200),'+#10+ ' deviceid varchar(15),'+#10+ ' severity int,'+#10+ ' remarks varchar(200), '+#10+ ' primary key ("idx") compress full'+#10+ ' ) '; with qryCretetbl do begin sql.Clear; sql.Add(v_sql); execSql; end; qryCretetbl.Free; end; procedure Tfrmtestdbisam.FormShow(Sender: TObject); begin CreateTable; Timerinsert.Enabled := true; TimerQry.Enabled := true; end; procedure Tfrmtestdbisam.TimerinsertTimer(Sender: TObject); var inserttbl: TDBISAMTable; i: integer; begin Timerinsert.Enabled := false; for i := 0 to 10 do begin inserttbl := TDBISAMTable.Create(nil); with inserttbl do begin DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; tablename := 'incident'; active := true; Append; fieldByName('receiveddate').Value := now; FieldByName('atkdate').AsString := FormatDateTime('yyyy-mm-dd',now); FieldByName('atktime').AsString := FormatDateTime('hh:nn:ss',now); FieldByName('sourceip').AsString := '1.1.1.1'; FieldByName('sourcenum').AsString := '222222'; FieldByName('sourcename').AsString := 'source name'; FieldByName('targetip').AsString := '2.2.2.2'; FieldByName('targetnum').AsString := '33333'; FieldByName('targetname').AsString := 'dest name'; FieldByName('targetport').AsString := '80'; FieldByName('attacktype').AsString := 'attack type'; FieldByName('deviceid').AsString := 'deviceid1'; FieldByName('remarks').AsString := ' this is a testing app.'; post; end; inserttbl.Free; end; Timerinsert.Enabled := true; end; procedure Tfrmtestdbisam.TimerQryTimer(Sender: TObject); var thread: TThread; begin TimerQry.Enabled := false; thread := TCEThread.Create(True); thread.Resume; end; { TCEThread } procedure TCEThread.Execute; var Qry,Qrydel: TDBISAMQuery; begin Qry := TDBISAMQuery.Create(nil); Qry.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qry do begin Close; SQL.Clear; SQL.Add('select max(idx) maxidx from incident '); open; end; Qry.Close; Qry.Free; Qrydel := TDBISAMQuery.Create(nil); Qrydel.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qrydel do begin close; SQL.Add(' delete from incident '); execSQL; end; Qrydel.Free; frmtestdbisam.TimerQry.Enabled := true; end; end. ===this is a testing Source code=============== |
Tue, Mar 3 2009 3:55 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Garey
When you use threads you MUST isloate all DBISAM components. What you need in in your thread is the session component eg { TCEThread } procedure TCEThread.Execute; var Qry,Qrydel: TDBISAMQuery; ThreadSession:TDBISAMSession; begin ThreadSession:=TDBISAMSession.Create; ThreadSession.PrivateDir := GetWindowsTempPath; ThreadSession.AutoSessionName := True; ThreadSession.LockProtocol := lpPessimistic; Qry := TDBISAMQuery.Create(nil); Qry.SessionName := ThreadSession.SessionName; Qry.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qry do begin Close; SQL.Clear; SQL.Add('select max(idx) maxidx from incident '); open; end; Qry.Close; Qry.Free; Qrydel := TDBISAMQuery.Create(nil); Qry.SessionName := ThreadSession.SessionName; Qrydel.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qrydel do begin close; SQL.Add(' delete from incident '); execSQL; end; Qrydel.Free; frmtestdbisam.TimerQry.Enabled := true; end; Roy Lambert |
Tue, Mar 3 2009 10:01 PM | Permanent Link |
Garey | Roy Lambert wrote:
Garey When you use threads you MUST isloate all DBISAM components. What you need in in your thread is the session component eg { TCEThread } procedure TCEThread.Execute; var Qry,Qrydel: TDBISAMQuery; ThreadSession:TDBISAMSession; begin ThreadSession:=TDBISAMSession.Create; ThreadSession.PrivateDir := GetWindowsTempPath; ThreadSession.AutoSessionName := True; ThreadSession.LockProtocol := lpPessimistic; Qry := TDBISAMQuery.Create(nil); Qry.SessionName := ThreadSession.SessionName; Qry.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qry do begin Close; SQL.Clear; SQL.Add('select max(idx) maxidx from incident '); open; end; Qry.Close; Qry.Free; Qrydel := TDBISAMQuery.Create(nil); Qry.SessionName := ThreadSession.SessionName; Qrydel.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qrydel do begin close; SQL.Add(' delete from incident '); execSQL; end; Qrydel.Free; frmtestdbisam.TimerQry.Enabled := true; end; Roy Lambert thanks Roy, using session, but now another problem, #8962 Data record buffers corrupt in the table incident I try to repair the incident table ,but show #11013 error msg. pls help me, many thanks, delphi 6+dbisam4.05 ===the testing source code================ unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DB, dbisamtb, StdCtrls, Grids, DBGrids, dbisamct; type Tfrmtestdbisam = class(TForm) Timerinsert: TTimer; TimerQry: TTimer; procedure FormShow(Sender: TObject); procedure CreateTable; procedure TimerinsertTimer(Sender: TObject); procedure TimerQryTimer(Sender: TObject); private { Private declarations } public { Public declarations } end; TCEThread = class(TThread) protected procedure Execute; override; end; var frmtestdbisam: Tfrmtestdbisam; implementation {$R *.dfm} procedure Tfrmtestdbisam.CreateTable; var filepath: String; v_SQL: String; qryCretetbl: TDBISAMQuery; begin qryCretetbl := TDBISAMQuery.Create(nil); filepath := ExtractFilePath(Application.ExeName)+'cedb'; qryCretetbl.DatabaseName := filepath; v_sql := ' CREATE TABLE IF NOT EXISTS "INCIDENT" '+#10+ ' ( '+#10+ ' idx autoinc,'+#10+ ' receiveddate timestamp,'+#10+ ' atkdate Date,'+#10+ ' atktime time,'+#10+ ' sourceip varchar(15),'+#10+ ' sourcenum integer,'+#10+ ' sourcename varchar(50),'+#10+ ' sourceport varchar(10),'+#10+ ' targetip varchar(30),'+#10+ ' targetnum integer,'+#10+ ' targetname varchar(30),'+#10+ ' targetport varchar(30),'+#10+ ' attacktype varchar(200),'+#10+ ' deviceid varchar(15),'+#10+ ' severity int,'+#10+ ' remarks varchar(200), '+#10+ ' primary key ("idx") compress full'+#10+ ' ) '; with qryCretetbl do begin sql.Clear; sql.Add(v_sql); execSql; end; qryCretetbl.Free; end; procedure Tfrmtestdbisam.FormShow(Sender: TObject); begin CreateTable; Timerinsert.Enabled := true; TimerQry.Enabled := true; end; procedure Tfrmtestdbisam.TimerinsertTimer(Sender: TObject); var inserttbl: TDBISAMTable; i: integer; tblRepair: TDBISAMTable; ThreadSession: TDBISAMSession; begin Timerinsert.Enabled := false; for i := 0 to 10 do begin inserttbl := TDBISAMTable.Create(nil); with inserttbl do begin DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; tablename := 'incident'; active := true; Append; fieldByName('receiveddate').Value := now; FieldByName('atkdate').AsString := FormatDateTime('yyyy-mm-dd',now); FieldByName('atktime').AsString := FormatDateTime('hh:nn:ss',now); FieldByName('sourceip').AsString := '1.1.1.1'; FieldByName('sourcenum').AsString := '222222'; FieldByName('sourcename').AsString := 'source name'; FieldByName('targetip').AsString := '2.2.2.2'; FieldByName('targetnum').AsString := '33333'; FieldByName('targetname').AsString := 'dest name'; FieldByName('targetport').AsString := '80'; FieldByName('attacktype').AsString := 'attack type'; FieldByName('deviceid').AsString := 'deviceid1'; FieldByName('remarks').AsString := ' this is a testing app.'; post; Application.ProcessMessages; end; inserttbl.Free; end; Timerinsert.Enabled := true; end; procedure Tfrmtestdbisam.TimerQryTimer(Sender: TObject); var thread: TThread; begin TimerQry.Enabled := false; thread := TCEThread.Create(True); thread.Resume; end; { TCEThread } procedure TCEThread.Execute; var Qry,Qrydel: TDBISAMQuery; ThreadSession: TDBISAMSession; tblrepair: TDBISAMTable; begin try ThreadSession:=TDBISAMSession.Create(nil); ThreadSession.PrivateDir := ExtractFilePath(Application.ExeName)+'cedb'; ThreadSession.AutoSessionName := True; ThreadSession.LockProtocol := lpPessimistic; Qry := TDBISAMQuery.Create(nil); Qry.SessionName := ThreadSession.SessionName; Qry.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qry do begin Close; SQL.Clear; SQL.Add('select max(idx) maxidx from incident '); Qry.Prepare; open; frmtestdbisam.Writelog; end; Qry.Close; Qry.Free; Application.ProcessMessages; Qrydel := TDBISAMQuery.Create(nil); Qrydel.SessionName := ThreadSession.SessionName; Qrydel.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; with Qrydel do begin close; SQL.Add(' delete from incident '); Qrydel.Prepare; execSQL; end; Qrydel.Free; ThreadSession.Free; frmtestdbisam.TimerQry.Enabled := true; except tblrepair := TDBISAMTable.Create(nil); tblrepair.DatabaseName := ExtractFilePath(Application.ExeName)+'cedb'; tblrepair.TableName := 'incident'; if tblrepair.Exists then tblrepair.RepairTable(true); tblrepair.Free; end; end; end. ===the testing source code================ |
Wed, Mar 4 2009 2:32 AM | Permanent Link |
"Ralf Bieber" | Garey wrote:
Garay, > Append; > fieldByName('receiveddate').Value := now; > FieldByName('atkdate').AsString :=FormatDateTime('yyyy-mm-dd',now); > FieldByName('atktime').AsString := FormatDateTime('hh:nn:ss',now); > the code is running here with dbisam version 4.27 Build 4 and the following changes: Append; fieldByName('receiveddate').AsDateTime := now; FieldByName('atkdate').AsDateTime :=FormatDateTime('yyyy-mm-dd',now); FieldByName('atktime').AsDateTime := FormatDateTime('hh:nn:ss',now); Ralf |
Wed, Mar 4 2009 2:37 AM | Permanent Link |
"Ralf Bieber" | Ralf Bieber wrote:
> Garey wrote: > > Garay, > > > Append; > > fieldByName('receiveddate').Value := now; > > FieldByName('atkdate').AsString :=FormatDateTime('yyyy-mm-dd',now); > > FieldByName('atktime').AsString := FormatDateTime('hh:nn:ss',now); > > > > the code is running here with dbisam version 4.27 Build 4 and the > following changes: > > Append; > fieldByName('receiveddate').AsDateTime := now; > FieldByName('atkdate').AsDateTime :=FormatDateTime('yyyy-mm-dd',now); > FieldByName('atktime').AsDateTime := FormatDateTime('hh:nn:ss',now); > > Ralf correction Append; fieldByName('receiveddate').AsDateTime := now; FieldByName('atkdate').AsDateTime :=Date; FieldByName('atktime').AsDateTime :=now; Ralf |
Wed, Mar 4 2009 3:28 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Garey
From the manual 11013 means "Access denied to table or backup file" so you probably either have the table open elsewhere, or a crash has caused its handle to stay around in Windows somehow. The "cure" is to reboot the PC, open DBSys and do the repair before doing anything else. Roy Lambert [Team Elevate] |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |