Time to contact Delphi is not long, before one month ago, I still don't know what it is, I don't know the same, because I need to learn. However, the mandate is urgent, which is also an old saying: there is pressure to have power. Under the incomparably, it is studied and grasped its power to grow accordingly. I am trying to start, TTable, TQuery, and I will take a week to realize the limitations of BDE. Then turn to the ADO, another ADOCONNECTION, ADOTABLE, ADOQUERY. Later I gave up ADOTABLE and ADOQUERY, I have studied the half-day storage procedure, and I started to use AdoStoredProc. AdoStoredProc is really a good thing! The tube is returned to the data set, and the tube handles a table or multiple tables, is handed over to the SQL statement to get it, then just run it, then run it ... then is COM, DLL, every day there is new Discover that every day, every day, the circulation of confusion, annoyance, surprises, epiphany and reproduction, bother, surprises, and epiphany seem to have not ended, the only difference is just a cycle of cycles. Now look at Discovery, I heard that: "What new discovery did you have today?" It is thoughts. There are so many gossips, I just want to emphasize that if this task can be completed on time, it must be attributed to the collective wisdom! For the words, there is such a experience, no matter which language is written in any language, we will find some singularity: a place debugging, compares the comparison, obviously and that example, why Is it unsuccessful? Maybe you have two or three days, maybe it is no progress for a week. Oh, that is, you don't know that a little place, you didn't pay attention, a few days of work may all charge. This is the main content I want to talk. First of all, the following contents are all speaking, whispering, and unreasonable, perhaps not worth mentioning Delphi veteran, but if you are planning to start from scratch, maybe it will help you. One: Use Query who has used the Query control may all be able to use the SQL statement to make multiple table queries, modify or even insert, and delete the arrival. The process of using this type of control is usually created first --close - specifying the data source - write to the SQL statement - Finally run the SQL statement. There is a small place to be ignored, and different ways should be selected when the SQL statement is to be returned. If the result needs to return a result set, for example, use Open execution; otherwise execute with EXECSQL, such as insert, modify. Two: BDE and ADO databases have always been the advantage of delphi, which provides database applications via IDE (Integrated Development Environment), providing users with interface-database engines, making applications without directly accessing physical databases, greatly improved Design speed. BDE (BORLAND DATABASE Engine) is one of the interfaces that use BDE Administrator we can easily configure data sources, create and remove ODBC drivers, create and maintain database alias. But BDE is only available for Borland series products, and this convenient price is necessary to give up partial flexibility. The maximum impact is that the data source cannot be dynamically specified in the run phase. Fortunately, Delphi provides ADO to choose from. ADO (ActiveX Data Objects) provides a consistent, high-performance, highly compatible data access interface.
Use the ADO control to connect the data source, can be specified in the design phase or during runtime, another important advantage is that the ADO is built in Microsoft's operating system, so use ADO access to the database does not need to be The ADO is installed in a PC. Third: Get the parameters of the stored procedure to put the operation of the database on the server side, the benefits of using the stored procedure are obvious, one because the database server optimizes compilation, improves execution efficiency; two data The server is processed, which limits unnecessary data to customers. In the stored procedure, you can use the input parameter and return parameters. If the stored procedure is bound during the design phase, you can see that there is a @return_value in addition to the custom parameter in the parameter list, which reflects the storage process running status, In SQL Server, if the stored procedure runs successfully, return 0, otherwise it returns to 0. However, if you need to specify the stored procedure at the run phase, I found that the parameter list is empty, although the parameters can be added via the AddParameter method, but not @return_value. This problem has been bothering me for a long time, there is no @return_value to get around a large circle when it is judged, it is very inconvenient. Later, Liu Binbin accidentally found that Parameters had a way: refresh can reset the parameter list, so that the parameter can be dynamically added without manual, @ return_value problem is also solved. Four: Unintentional misses in calling the stored procedure, SQL query must be careful to check the field name, and if you can't find a field, it is very likely that the field name is wrong. Don't underestimate this seemingly weak problem, this small place is often the most inconspicuous, and it is also the most difficult to find mistakes. The lesson of our blood is the account and account, coordinates and coordinates, Date and Data, you have to be careful next time! Five: Use the parameters in the DLL to create a dynamic link library, we will see a large period of comments in the library unit, don't look at the comments, the comments here hide the mystery. Its great idea is as follows: Important prompts for DLL memory management (here you use 'important note'): If you introduce strings as parameters or return values in the process or function, you must THE FIRST Unit Sharemem Unit, and this convention also applies to Strings used in Record or classes. ShareMem is the interface unit of borlndmm.dll shared memory management, which will use PCHAR or ShortString instead of Strings if you want to use borlndmm.dll. During the actual use, we also found that the parameter values in the Transport Link Link will often be incorrect. In addition to following the above approach, we recommend that the function of non-display dynamic links is used in the dynamic link project. Create an interface unit to declare the function, introduce the unit in the application project, and then you are OK when you need to use the dynamic link library function. It seems that Delphi is not a simple thing. We have limited capacity. The above sculptor small skills are all experienced. For reference only, if there is something wrong, you still hope that Delphi master will enlighten me. On this way of exploring Delphi, we will continue to summarize some practical experiences and share it with you.