[转载]How to Use Delphi Multi-Tier Database Application Code Generator
<p>信息来源: <a id="ArticleTitle1_ArticleTitle1_AuthorLink" href="user/dogbear2000">dogbear2000</a></p><p><span id="ArticleContent1_ArticleContent1_lblContent"></span></p><p>Delphi Multi-Tier Database Application Code Generator 0.9<br />--Bear,.11.25</p><p>DMPCG is a FREE code generator for Delphi developers.</p><p>When developing MIDAS project, we need develop the Application Server and Client Application.<br />We need put Dataset component and Provider components for each table on Application Server side.<br />We need put ClientDataSet and DataSource components for each table on Client application side.<br />We need put DataAware components for each table and field on Client application side too.<br />We need give each component a readable name regarding its table name or field name.</p><p>If you have a lot of tables in database to deal with, it may take you several days.</p><p>DMDACG can do all of these work for you in several minutes.<br />The more tables you have, the more time it save for you.</p><p>How does DMDACG work?<br />=====================</p><p>1. Copy project template directory to output directory.<br />2. Connect to database via UDL file or connect to Access MDB file directly.<br />3. Replace the variable block in template and insert some code blocks:</p><p> On Server Side:<br /> A. Each table will have a DataSet and DataSetProvider components in RemoteDataModule<br /> B. Each DataSet will have persist field components.<br /> The first field will be looked as Primary Key.</p><p> On Client Side:<br /> A. Each DataSet will have persist field components.<br /> The first field will be looked as Primary Key.<br /> If the filedname is like *ID, we guess it is a Foreign Key, there will be a DBLookupComboBox for it.<br /> B. Each table will have a form with DBGrid for the table and DBEdit components and Label components for each field.<br /> C. There will be a form to hold all of the DBGrid components.</p><p>4. All of the component will be named well by the table name or field name.<br /> For example : Client_Frm, Client_DBGrid, Client_DBEdt, Client_Lab, etc.</p><p>5. You can change all of the default name format strings in NameFormat.ini</p><p><br />How to Use the DMDACG?<br />======================<br />1. Select template directory, you can select the default template directory: \MidasProject<br /> In fact you can edit the code in template directory to add more functions.<br />2. Select output directory<br />3. Select UDL file or mdb file<br /> You can also edit the database.udl and let it point to your own database,<br /> And then select the UDL file.<br />4. Select FieldName and DisplayText Map File, it is a text file. (Optional)<br /> If you use PowerDesigner to design the database, you can copy the field names and codes from the data item list to a text file.<br />5. Change other options. (Optional)<br />6. Click "Generate Project Source Code" button.</p><p>How to Use the output projects?<br />===============================<br />There will be two projects in the output directory.<br />One is for application server and another is for client GUI application.</p><p>1. Open the Application Server Project, run it to register the Remote Data Module COM.<br /> Then close it.<br /> If there is a "Database.mdb" file, The RDM will use it as the database, or it will use<br /> "DataBase.udl" file as the data connection file to connect to database. See the source code.</p><p>2. Open the Client GUI Project, open DataModule, select the ServerName from the CombboBox for the DCOM Connection.<br /> By default, the Connection Broker use DCOMConnection because it is handy to debug.<br /> You can use other connection too.<br /> And there is a Config.ini file in Exe directory.<br /> The client will read it at runtime to decide use which connection. (DCOMConnection,SockectConnection or WebConnection)<br />3. Run the Client GUI Project,<br /> you can edit the the data and post for each table now!</p><p>4. Redesign the forms or copy and paste these components to your own forms.<br /></p>页:
[1]
