Welcome to the second chapter of the FREE online programming course:
A Beginner's Guide to Asp.Net Programming for Delphi developers.
Getting started with the Delphi 8 BDSWebExample: restoring the database, preparing the virtual directory. Running BDSWebExample for the first time!
BDSWebExample: Delphi 8 ASP.NET Portal Example
As announced in the first chapter of this course, the entire course focuses on creating web applications in ASP.NET using Delphi 8. To help you get started creating your web applications as quickly as possible, we'll explore the inner workings and the source code of the ASP.NET demo application that ships with Delphi 8: BDSWebExample.
The purpose of the BDSWebExample is to show how to build a Borland's "CodeCentral"-like web site using ASP.NET and Delphi.
In this chapter, our goal is to configure the database and to set up the virtual directory - just to be able to run the BDSWebExample for the first time.
This is what we need to do today:
- Restore the database
- Configure the web server
- Run and "browse" through the example
The BDSWebExample can be found in "C:\Program Files\Borland\BDS\2.0\Demos\DB\ASPPortal\BDSWebExample" on a default install. For the moment, your only task is to locate that directory - in the following chapters we'll take a closer look at the folder contents.
Note: make sure you download the updated version of the code. The new version has more meaningful names for Web forms, and the code is cleaned up from using "Free" (since there is no need to free objects in .NET - the garbage collector does the ob for you) and some "defects". The database has not changed.
Also, to follow up with the chapters it would be best if you save the project under "C:\Inetpub\wwwroot\BDSWebExample"!
The database
An ASP.NET Web application is just a fancy name for a dynamic Web site. ASP.NET applications usually store information in a database on the Web server, and allow visitors (or only "administrators") to the site to access and change that information.
Our first task is to "create" the database. In the (original) "...\Demos\DB\ASPPortal" folder you'll find the "OWEBackup.bak" file and the "readme_first.txt" file (actually do as the name suggests :)). The OweBackup.bak is the backup of the MS SQL Server database. If you do not have SQL Server, you can use MSDE (*free* version of MS SQL Server). Both the SQL Server and the MSDE are database management systems much like Interbase from Borland (or MySql, or Firebird, or DB2 etc).
Why MS SQL Server/MSDE, why not Interbase, MySQL, etc...
No, I don't think SQL Server is better than Interbase. When the BDSWebExample example was under development - the *only* supported DBMS system (available to me) for building ASP.NET applications was MS SQL Server.
If you have MS SQL Server installed on your computer, here are the steps to restore the database from the OWEBackup.bak (or, if you do not, read below):
1. Run SQL Server Enterprise Manager
2. Right click "Databases", select "All Tasks - Restore Database"
3. In the "Restore database" dialog window, select a "From device" from the "Restore" radio group. Name the database "d4NetSoft" in the "Restore as database" drop down list box.
4. Hit the "Select devices" button and pick the "C:\Program Files\Borland\BDS\2.0\Demos\DB\ASPPortal\OWEBackup.bak" file.
5. Select the "Options" tab. Make sure that the "Restore As" paths exist in the "Restore database files as" list view (there's no need to change the names of the .mdf and the .ldf files).
6. Hit "Ok", wait until the restore process is complete .. and you are done.
"But I don't have MS SQL Server?!"
Ok, don't panic. You can use MSDE (direct download here). MSDE *is* SQL Server (it has all of the features of SQL Server 2000) - with three limitations: it supports up to 2 gigabytes (GB) per database, none of the GUI tools (like Enterprise manager) are provided with the MSDE, it limits up to five concurrent batch workloads for optimal performance (the system slows done after more than 5 connections).
Here's what you need to know about MSDE: it's a *free* personal database built on core SQL Server technology; it is fully compatible with SQL Server, you can easily target both SQL Server and MSDE with the same core code base; there is no GUI manager from MS.
No GUI? Yep, sad. However, there are a few third-party tools that can help you manage and administer MSDE databases. I would suggest "DbaMgr SQL Tools" (a free tool capable of managing and administering servers, databases and database objects from a Windows interface similar to the Microsoft Enterprise Manager).
Restoring under a different name...
If, for any reason, you need to restore the database under a different name than "d4netsoft", you'll need to edit the web.config file in the "C:\Inetpub\wwwroot\BDSWebExample" folder.
The web.config file is an XML file - ASP.NET application configuration containing application specific settings. Note that you do not need to launch Delphi 8 in order to edit the web.config - just use Notepad (as we are not going to discuss web.config today).
Ok, so now we have an operational DB. Our next task is to create a virtual directory under IIS.
Next page > Setting the virtual directory. Running BDSWebExample for the first time > Page 1, 2
A Beginner's Guide to ASP.NET Programming for Delphi developers: Next Chapter >>
>>
What makes an Delphi 8 Asp.Net application