| RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To |
| ISAPI tutorial for Delphi developers | |||||||||||||||
| Page 13: Database enabled applications - Part 1 | |||||||||||||||
I am going to base chapter 11 on constructing a client database. In this part, I will show you how to setup the TDatabase and prepare the web-module for multiple accesses to the database. In the next part I will cover insertion and updates (deleting aswell) of records.
First of all, let's create our database. Run the SQL file DBSTRUCT.SQLto generate the database file. Make sure you change the machine.domain: c:\databases\client.gdb to the appropriate settings for your machine. Next, let's configure the BDE.
Like any other BDE application, during development I have set the ENABLE SCHEMA CACHE to False. On deployment, change this to TRUE. Before going any further, check to see everything is working ok by opening the database from the BDE.
Your BDE settings should look something like this:
Now that we have our database and BDE configured, let's start a new ISAPI project. Once this is done, drop a TDatabase and a TSession on the form and set the following properties for each one:
TDatabaseTSession Of course, in real life you would not be setting the username and password at design time but at runtime. This is just for demonstration purposes. If you have Delphi 5, you will notice that the red circles will disappear in the designer as soon as you set the AutoSessionName = True. What this does is take care of giving each request a unique session to access the data safely and not interfere with any other petitions.
Now let's code a bit. We want to open the database when the DLL is first loaded and close it when the DLL is destroyed, thus preventing each request having to open/close the connection. To do this, we place the following code in the OnCreate/OnDestroy of the web module. Remember that this works as mentioned if you leave CacheConnections set to the default value of True. If you set CacheConnection to False (Application.CacheConnections := False), then every request will call the OnCreate/OnDestroy.
Next, we create a DEFAULT web action that just replies with 'Invalid Request'. Later on, when I make use of the BeforeDispatch we will see that we can control this there and not have to create a default action. In any case, it's not harmful and doesn't effect us at this point.
So this covers our first part of Page 11. Easy wasn't it? In the next part we are going to add the ability to insert/update and delete clients over the web.
Next page > Database enabled applications - Part 2 > Page 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
|||||||||||||||
All graphics (if any) in this feature created by Zarko Gajic.
| More Delphi |
|
· Learn another routine every day - RTL Quick Reference. · Download free source code applications and components. · Talk about Delphi Programming, real time. · Link to the Delphi Programming site from your Web pages. · Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC. |
|
· NEXT ARTICLE:
ADO Cursors - DB/10. Chapter ten of the free Delphi Database Course for beginners. How ADO uses cursors as a storage and access mechanism, and what you should do to choose the best cursor for your Delphi ADO application. |
| Stay informed with all new and interesting things about Delphi (for free). |
|
|
| Got some code to share? Got a question? Need some help? |

