V. Dynamic creation application
In actual applications, some tables should be created during the running process, and BDE can make it easy.
In the first one, we have already discussed the way to create and delete a table, here, you have done some content.
1. Type of data sheet
The TableType property is default TTDEFAULT. When the TableType property is TTDefault, the BDE determines the type of data sheet from the file name extension. The tableType property value is listed below:
Value data sheet type
TTDEFAULT automatically determines the data table type by BDE
Ttparadox Paradox
TTDBase DBase
TTFOXPRO FOXPRO
Ttascii separates ASCII
2, index properties
Options is used to specify the requirements that must meet the fields listed in the parameter f. It is a set type variable that can take several values such as IxPrimary, Ixunique, IxDescending, IxExpression, IxcaseInSitive, and Ixnonmaitained.
IXPrimary: Main index;
IXUnique: Unique key value, does not allow repeated values;
IXDescending: The index order is large to small (the default value is small to large);
IXEXPRESSION: Composite Index, the composite field and the fields are separated by plus sign;
IXCaseInSensitive: Index fields are unlimited in cases (default is not case sensitive);
IXnonmaitained: When the field data changes, BDE does not automatically help the data table reconstruction index (the default will be automatically reconstructed).
3, dynamically create alias
For BDE-established applications, alias is particularly important, and many methods need to pass a database alias as parameters. Fortunately, TSESSION provides the function of managing BDE alias. And all database applications will automatically include a default session. In the process of programming, we have encountered this situation, and the program is good, but when it is necessary to release, the program does not find alias. Unable to run, so you must use it on a machine that has already installed the BDE manager, you must be very disappointed. In fact, you can add the following statement in the program, and your program can execute. The Addalias method creates a new BDE alias for a SQL database server. It has three parameters: a string containing the alias name, a string that specifies the SQL Links driver name to use and a list of strings that contain alias parameters. Addstandardalias creates a new BDE alias for the ParaDox / DBase or ASCII table. It also has three parameters: alias name, to access the full path name of the ParaDox / DBase table and the name of the default driver used to try to open a table without an extension.
To access an Interbase server to the default session, the following statement adds a new alias using the Addalias method: tstringlist * aliasparams = new tstringlist ();
Try
{
AliaSparams-> Add ("open mode = read");
AliaSparams-> Add ("user name = myname");
AliaSparams-> Add ("Server Name = IB_SERVER: /PATH/Database.gdb");
Session-> Addalias ("Workname", "INTRBASE", AliaSparams
......
}
Catch (...) {
Delete aliasparams;
TROW;
}
Delete aliasparams;
To access a table, we can create a new alias in the AddStandAlias method.
Session-> Addstandardalias ("MyTable '," C: // Path // Table // "," Paradox "); to explain, the alias that calls the AddStandAlias or Addalias function exists only in memory, and then the program is closed No, you want to save the alias to the BDE configuration file, call the Saveconfigfile function.
Through these instructions I think you have been able to create a table, for visualization components, actually use New, but it is fully created, but the location setting of the component is not intuitive, it is best not to do it, of course you are interested, You can try it yourself.
It is limited to the space here.
Sixth, DBGRID, TQuery components Tips
(1) DBGRID Control 1. Setting the DBGRID field Display Width Properties To create a smaller column in DBGRID, you must establish a display title, which is equal to or smaller than the field value. For example, you want to build a column with only three characters wide, your column header shows that there must be only three characters or less. 2. Change the display field of DBGRID and date Display Format (1) Double-click the table1 corresponding to the DBGRID and enter the field editor. Note that the editor of Table1 is entered. (2) Right-click "Add Fields ...", the Add Fields ... ", the Add Field dialog box, select the field you want to add (this field will be displayed by DBGRID when running) and point OK button. (3) Assumption Add the "Date" field, click this field, in the property table: DISPLAYLABEL Fill in the field name you want DBGRID display. If the original field name is in English, here DBGRID will display the Chinese name with the Chinese name. Fill in DISPLAYFORMAT: YYYY-MM-DD, will be displayed in 1999-05-28 format later. Of course, in BCB6 we pass the object tree window, first find table1, then find the Fields below, then right click on it, and we can complete these operations through the shortcut menu.
(2) The TQuery control TQuery control is a very important control in database programming. It is responsible for establishing contacts through BDE and database, through SQL statements, easy to establish queries. Query must establish the corresponding SQL to take effect. The parameter settings of TQuery are as follows: (1) In the SQL property: SELECT * FROM table name Where field name =: Variable name follows ":" The variable is made. After writing, the data type of the variable can be modified in the parameter properties. (2) Assignment of variables: query1-> Active = false; query1-> params-> items [0] -> asstring = edit1-> text; query1-> active = true; // Find records of variables
(3) Display the result of DBGRID DataSource and DataSource1 connections, while DataSource1 is connected to the TQuery1. (3) The application example is easier and more efficient than Table by the Query Control Embed SQL statement. Use a simple code to explain how to create a query program: For example, to create a program in the name column in the table, add DBGRID, Datasource, Query on the form to add the following code: dBGrid1-> DataSource = DataSource1-> datasource1-> dataset = tqery1; query1-> close (); query1-> sql-> clean (); query1-> sql-> add ("SELECT * FROM table where (Name = 'myname'"); query1 -) Open (); For the query of the returning result set, in other words, if there is one or more data, such as the select command, you want to use the Active property or Open method, but only execute an action on the data table You can use the ExecSql method to run when you have queries such as Insert, udate, such as insert, udate. However, the BCB does not have a hard rule, and what method must be used, so when can I use Open, so when I can't get it, I will definitely use her.
Other visual components are similar, not much.
7. Database independently run the required document
Both BCB programmers know that after the database application is completed, it is necessary to publish the program to publish BDE (BORLAND DATABASE ENGINE), otherwise the error will cause an error "A Error Occurred While At Temping to Initilize Borland Database Engine (ERROR $ 2109)". When the program is too big and hard to streamline your own procedures, it is found that the BDE management programmer needs 17.4m. It is not as frustrated, so many people don't like BDE, but as long as you have a brain or a way to compress BDE of. First take a look at the files in the BDE directory, all the files do have nearly 17.4m big. However, some may not be used. The following is the role of each file: (1) An indispensable file BLW32.DLL: Language drive function library. Idapi32.dll: BDE Basic Library. FareAast.btl, USA.BTL: Far East language and American language drivers are indispensable to Chinese software. IDR20009.DLL: Error Information Library. (2) Database driver (select one or more) iDasci32.dll: ASCII text database driver function library, if you do not need ASCII text database, you can not. IDDAO32.DLL: Access database driver log library, if you don't need Access database, you can. IDDBAS32.DLL: DBase database driver log library, if you don't have a dbase database, you can. IDODBC32.DLL: ODBC Database Driver Release Library, if you don't have to use an ODBC database, don't. IDPDX32.dll: Paradox Database Driver Release Library, if you don't have to use the Paradox database, you can. (3) Other drivers and profiles (select one or more) iDbat32.dll: Batch operation driver function library, if you do not need to use the TBatchMove control or dbibatchMove class function, IDDR32.DLL: Data Repository driver function library, if you don't have to use a Data Repository function, you can. IDPROV32.DLL: BDE Dataset Provide driver log library, if you don't have to use the TPROVIDER control, please don't. Note: In BCB6, there is no file, she is just a file that appears in the earlier version. IDQbe32.dll: QBE driver function library, if you don't have query by example, you can. IDSQL32.DLL: SQL query driver log library, if you don't have to query with TQuery, don't. IDapi32.cfg: BDE configuration file, if there is no special requirements in the program, don't. You can also set the correct and then distributed in the BDE manager. (4) Other documents (generally not) BDE32.HLP, BDE32.cnt: BDE help file, you can.
BDEADMIN.EXE, BDEADMIN.HLP, BDEADMIN.CNT: BDE Manager, and help files, if you don't need software users to configure BDE yourself, you may not. Other * .bll: Language drivers in other countries and regions, don't. DataBump.exe, DataBump.hlp, DataBump.cnt: Database Data Transfer Tool and Help File, you can. Localsql.hlp, localsql.cnt: SQL query statement help file, don't. SQLLNK32.HLP, SQLLNK32.cnt: SQL Connection Help file, you can. After selecting the file as needed, you should write a registry file. This should not be a problem, it can be manually set, but it is best to set in the program. When there is no corresponding key value in the discovery registry, you can't use a few lines of code with the TREGFILE object. The registry key value that needs to be set is (required to have the correct key value before calling the database operation): Settings of the directory where the data driver is located: HKEY_LOCAL_MACHINE / SOFTWARE / BORLAND / DATABASE ENGINE / DLLPATH (string value) Language driver Directory setting: HKEY_LOCAL_MACHINE / SOFTWARE / BORLAND / BLW32 / BLAPIPATH (string value) Language driver file name: hkey_local_machine / software / borland / bLW32 / local_lib # (string value)
Where # is numbered, according to 0, 1, 2, 3 ... .bll "This can greatly reduce the BDE driver, such as using the TTable control to operate the Paradox database, as long as Idapi32.dll, bLW32.DLL, IDR20009.DLL, FAREAST.BLL, USA.BLL, IDPDX32.DLL six files I.e. These files can be placed in any directory, as long as the registry is indicated. OK, BDE is only 2m after slimming, and ZIP is more than 700 K, which is much lower than the original application system.
Of course, the above content can be done when the package is packaged, you can see if you don't have any problems in English, if you think that you think excess BDE files in the Advanced tab, then your setting must not be correct, no Method, turn again, save some, the smaller, the better, J
The packaging is impossible here, practical is our best teacher, compress your file in practice J
The elegance of BDE is the perfect combination of her with BCB. She can create more functions with very few components, which can be better combined with other (non-BDE) components .... Today, BDE turns this. BDE is also the reason. It is not clear how they think, in the database development software radiant today, if Baishi doesn't have something on this, then we like BCB May not have any "money" map. There is no way, it may be true, BDE has become a garbage of no one. L this wanted to write this article more details, like Tabel slimming, the rapid establishment of the master-slave table, the BDE implements the blob field reading and writing , BDE's SQL application, BDE and QR, etc., today, this is a bit too much, no way, I really can't write again, because this time I don't end, those who are, I can't stand L. It's not a good thing, many people don't even want me to write, but I don't always feel a problem, so I will take the opportunity to end.
(Full text)