Re: Access Violation in multitier application
Posted by webmaster Guido
on October 15, 2001
In Reply to: Access Violation in multitier application posted by Olivier on October
: I am developing a multitier application, with a UI tier, a domain tier and a DB tier. I use
record structures to store data between the database and the domain units. I then transfer the records
data to an object in the domain in the constructor Create. This is apparently wrong, because i keep getting
an access violation. Please look at the code below, and post an answer (or mail me) as soon as possible,
because time is a major issue!!!
: unit Main;
: // interface and more
: procedure THovedV.Button1Click(Sender: TObject);
: var p1 : TPoint;
: Label1.Caption := IntToStr(p1.GetValue);
: unit PointU;
: uses Main;
: type TPoint = class
: Point_id : integer;
: Value : integer;
: constructor create(P_id : integer);
: destructor destroy; override;
(and so on... see original message for full code)
Seems a bit dangerous to me that you redefine TPoint, which is a Delphi type. The Help says:
TPoint type defines a pixel location onscreen.
type TPoint = record
The TPoint type defines a pixel location onscreen, with the origin in the top left corner. X specifies the horizontal coordinate of the point, Y specifies the vertical coordinate.
I don't know if it is relevant in your case, but just a tip: why not rename your own TPoint to TPointX or similar, i.e. avoid redefining an already existing type?
I know, this has nothing to do with DB key violations, but it's better to play on the safe side ;-)
As for the key violations: try to write a simple test program with only one unit, that contains a simplified version of what you try to do. Don't do any fancy stuff with TPointX or so, keep it very basic. Example: your one and only "test" unit contains just a TButton as its interface; clicking the button just creates a record (hard-code everything: that makes it very easy to debug.
If that works, modify the code as to update an existing record. Next, add an editbox for the data. And so on, step by step. Don't get me wrong, I'm not questioning your programming abilities. But writing such an humble test proggie often solved my problems, because we don't see the obvious anymore when working too long with the "real" production code ;-)
Related Articles and Replies
[ Related Articles and Replies ] [ DelphiLand FAQ ] [ Delphi Tutorials ]