Solved

Need to checksum a record before it enters a database table

Posted on 2001-06-15
5
251 Views
Last Modified: 2010-04-06
Hi guys,

I have data that enters a *.dbf table. But before that I need to checksum this data if it meets a certain aritmetical formula. The data enteres the *.dbf table through a DBEdit object.

How do I do this?

Greetings,
Blash
0
Comment
Question by:blash
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6194791
Hi Blash

  you can check about ur value in the even before post, and if the value not as you want to save you can cancel the operation

procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
  If StrToInt(DBEdit2.Text) < 50 then
  begin
    ShowMessage('Value must be greeter than 50');
    Table1.Cancel;
  end;
end;

Best regards
Mohammed Nasman

 
0
 

Author Comment

by:blash
ID: 6201310
Thank you Mohammed.
It does the job.

Now how do I exit properly from this procedure, without
geting the error message,
with an 'exception'?
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6201870
Hello Blash

  I'm glad that work fine with you, but tell me what's the error message that you got?, could u plz tell me the error messages, and if you can post ur code to see that's wrong with it
 

Mohammed
0
 

Author Comment

by:blash
ID: 6201948
Access violation at address 0045FCF2 in module 'P1NALOPR.EXE'.Read of address FFFFFFFF
0
 

Author Comment

by:blash
ID: 6202035
unit U1zbnzpr;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, Mask, DBCtrls, Db, DBTables, Grids, DBGrids,
  FMXUtils;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    Label4: TLabel;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    DBEdit6: TDBEdit;
    Label10: TLabel;
    DBEdit7: TDBEdit;
    Label11: TLabel;
    DBEdit8: TDBEdit;
    Label12: TLabel;
    DBEdit9: TDBEdit;
    Label13: TLabel;
    DBEdit10: TDBEdit;
    Label14: TLabel;
    DBEdit11: TDBEdit;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    StaticText1: TStaticText;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    DBEdit16: TDBEdit;
    DBEdit17: TDBEdit;
    DBEdit18: TDBEdit;
    DBEdit19: TDBEdit;
    DBMemo1: TDBMemo;
    DBMemo2: TDBMemo;
    DBMemo3: TDBMemo;
    DBMemo4: TDBMemo;
    DBEdit20: TDBEdit;
    DBEdit21: TDBEdit;
    DBEdit22: TDBEdit;
    DBEdit23: TDBEdit;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    DBEdit24: TDBEdit;
    DBEdit25: TDBEdit;
    DBEdit26: TDBEdit;
    DBEdit27: TDBEdit;
    DBEdit28: TDBEdit;
    DBEdit29: TDBEdit;
    DBEdit30: TDBEdit;
    DBEdit31: TDBEdit;
    Image1: TImage;
    DataSource1: TDataSource;
    Table1: TTable;
    DBGrid1: TDBGrid;
    DBEdit32: TDBEdit;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Table2: TTable;
    DataSource2: TDataSource;
    Button1: TButton;
    Database1: TDatabase;
    Query1: TQuery;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Table2AfterCancel(DataSet: TDataSet);
    procedure Table2AfterPost(DataSet: TDataSet);
    procedure Table2BeforePost(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
DBEdit9.Text := FormatDateTime('dd.mm.yyyy',Now);
FMXUtils.CopyFile('c:\windows\desktop\zbnalgl0.dbf','c:\windows\desktop\temp\');
RenameFile('c:\windows\desktop\temp\zbnalgl0.dbf', 'c:\windows\desktop\zbnalgl.dbf');
Table2.TableName:= 'zbnalgl.dbf';
Table2.Active:=True;
//

//
end;

procedure TForm1.Button1Click(Sender: TObject);
var t:ttable;
begin
Table2.Post;
Table2.Close;
//moe
Table1.Open;
Table2.Open;
//od EE
//
Table2.Edit;
DBEdit9.Text:=DateToStr(Date);
Table2.Post;
//
t := ttable.create(nil);
try
  query1.open; //this query contains the sql-statement
  t.databasename := query1.databasename;
  t.tablename := 'c.dbf';
  t.batchmove(query1,BatCopy); //this will create the table and insert the records from tableA
finally
 query1.close;
  t.free;  //release object instance
end;
//moe
Table2.Close;
//moe2
end;


procedure TForm1.Table2AfterCancel(DataSet: TDataSet);
begin
Table2.Active:=False;
end;

procedure TForm1.Table2AfterPost(DataSet: TDataSet);
begin
Table2.Active:=False;
end;

procedure TForm1.Table2BeforePost(DataSet: TDataSet);
begin
  if StrToInt(DBEdit7.Text)<50 then
  begin
   ShowMessage('Vrednosta mora da e pogol. od 50');
   Table2.Cancel;
  end;
end;

end.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question