Solved

Need to checksum a record before it enters a database table

Posted on 2001-06-15
5
245 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:
mnasman earned 50 total points
Comment Utility
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
Comment Utility
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:mnasman
Comment Utility
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
Comment Utility
Access violation at address 0045FCF2 in module 'P1NALOPR.EXE'.Read of address FFFFFFFF
0
 

Author Comment

by:blash
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now