1. Use SQL language in Delphi
Because the SQL language is easy to use, rich in functions, and simple and easy to learn, it is deeply loved by database developers. In Delphi, executing SQL code is very easy to implement by using controls such as Query, DataSource, etc., but when it comes to date queries, you will encounter a problem that is easy to ignore. Suppose the data table used is orders.db, and there is a date field that is salesedate. When browsing the data table, the format of sales is displayed as: yyyy-mm-dd (year-month-day). The SQL code is: select*fromorderswheresaledate>1998-03-31 However, the error of "typemismatcheXPression" is always displayed when executing the code. The author thought it was caused by incomplete installation of the database engine (BDE), so he reinstalled Delphi, but found that the problem still exists. After repeatedly checking the SQL information and online help, I finally found that BDE only supports the date format in the United States. Its format is: mm/dd/yyyy (month/day/year). Change the SQL code to: select*fromorderswheresaledate>03/31/1998 The problem is excluded when executing the code again. In order to make the date format consistent when querying and other data operations, it is recommended to set the area to: English (US) in the locale settings item in the control panel.
2. Call Word documents in Delphi
OLE is a way to allow different applications to work together and share data. A Word document can be linked or embedded into a Delphi program through the OLEContainer component located on the System page of ComponentPalette. After the application debugging was completed, the author installed the application and Word97 on the user's computer to run it. When calling the Word document, an error message "The source target of the link has been changed" appeared. Carefully checked, the program code was correct, and it was repeatedly debugged and run, and found that some Word documents could be called normally. This part of the documents is in Word97 format, and the documents that cannot be called are the original Word6.0 format documents of the user, so this part of the documents is included. Convert to Word97 format, run again, the program is normal. It can be seen that when writing OLE applications, you should pay attention to the format of sharing data, otherwise unnecessary time and energy will be wasted.