Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Propagating constraints from middle-tier to client


How do I propagate constraints from Middle-tier to Client?   

    This example uses the demos found in \Delphi 3\Demos\DB\CLIENTDS\Empedit.dpr and \server.dpr. Empedit.dpr represents the client tier, server.dpr runs on the middle tier, and the database, DBDEMOS, is located also on the middle tier, but in a real world scenario would be an SQL database running on yet a third machine. This example uses the Employee.db table. In order to use the following, you will need to set up DCOM and have the two examples running before adding the complication of constraints to the mix. The general steps are: Define constraints in the data dictionary Associate the data dictionary attributes to a TField Access the TField from a ClientDataSet.

    First, define an attribute set in the data dictionary that includes a constraint. For instance, an attribute set called EmpNoA could have a CustomConstraint of "EmpNo > 00" and a ConstraintErrorMessage of "EmpNo is less than 00". Define static TFields in Server.dpr. Bring up the EmpServer datamodule and double click EmpQuery to bring up the fields editor. In the fields editor, right-click the EmpNo TField, select Associate Attributes, and select EmpNoA from the Associate Attributes dialog. Now when selecting the EmpNo TField in the fields editor you should see CustomConstraint and ConstraintErrorMessage matching the data dictionary entry. Open EmpEdit.dpr and add a TDBEdit to EmployeeForm. Set the DataField property to EmpNo and the DataSource property to EmpData (the TClientDataSet). Compile and run Server.dpr on the middle tier machine, then on the client machine run the EmpEdit example application. Attempt to post a record where EmpNo is greater than 00; your custom error message will appear.

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use