Thursday, May 19, 2011

connection of database in frontpage


You might not want FrontPage 2003 to create an entire Web-based interface for your database needs.  You might instead require database elements to be integrated into your existing Web site.  The rest of this paper will explain how to do just that.

Steps to Creating a Simple Form in FrontPage 2003

To create a new page with a feedback form:

·         Select File | New | Page or Web.  This will open the New Page or Web task pane.  Select Page Templates from the task pane.  The Page Templates Dialog Box will appear.

·         In the “General” tab, select “Feedback Form.”

·         Click “OK” in the lower right-hand corner of the “New” dialog box.

·         Edit the form to represent your specific needs.  You can see FrontPage Help (F1) for more information on how to edit and customize forms.

·         Select File | Save.

·         Name the page “feedback.asp” and click “Save”.

Note: You don’t have to use the Form Wizard to create forms in FrontPage 2003; it is one tool that might make form creation easier.  You can create any kind of form one piece at a time with individual form elements, by selecting Insert | Form, and then adding form fields to suit your needs.

Managing Forms and Databases

Once the customer feedback form is created, you can then use FrontPage 2003 to either save the results to an existing database or create a new database to save results to.  FrontPage 2003 will connect to any database that can connect via ODBC, the Open Database Connectivity standard.  It is important to note that the only type of database FrontPage 2003 can create is an Access database.

Creating a Database Within Your Web

It is easy to create a database from scratch using FrontPage 2003.  Once you have completed your form, follow these simple steps to automatically create a database in which to store your form information.

·         Right click inside the form boundary (the dotted line).

·         Select “Form Properties”.  This will open up the “Form Properties” dialog box.

·         Select the “Send to database” radio button.

·         Click the “Options” button in the lower left-hand corner of the Form Properties dialog box.  This will open the “Options for Saving Results to Database” dialog box.

·         Click on “Database Results” tab.

·         Click the “Create Database” button.  FrontPage will create a new Access database, as well as the database connection in global.asa that you can use for later reference to that database.  An alert will pop up to let you know when FrontPage 2003 has finished this process.

·         Click “OK” to dismiss the alert.

·         Click the “OK” button in the lower right-hand corner of the “Options for Saving Results to Database” dialog.

·         Click the “OK” button in the lower right-hand corner of the “Form Properties” dialog.

·         Save the page (make sure that it is saved with an .asp extension).

FrontPage 2003 will name the database based on the title of the page you created the form on.  A Results table will be created in the database and will contain one column for each form field as well as some additional columns (Remote Computer Name, User Name, Browser Type and Timestamp) that you might find useful.

You can test the form by publishing your Web site to your Web server and then viewing the page you’ve just created in the browser.  Go ahead and complete the form and then click the Submit button.  You can verify that the form results were saved to your database by creating a Database Results Region described below in Displaying Form Results.  That’s it!  Just a few steps and FrontPage 2003 will create a database for your site and write all of the ASP code required to save form results to the database.

Sending Form Results to an Existing Database

Part of the power of database integration with FrontPage 2003 is that you don’t have to start from scratch.  You may already have an existing Access database that you would like to integrate with your Web site.  To do this, you must first import the database into your Web site and create a connection to it.  This too, is easy, and you have two options to help carry it out.

The first option is to simply import that database by selecting File | Import from FrontPage 2003.  This will open an Import dialog box that will let you add any file to your Web site.  You can add your database to your existing Web using this method quickly and easily.

The second option entails taking advantage of the drag and drop features provided by FrontPage 2003.  Again, the power of being integrated with a larger Office Suite becomes clear if you follow this path:

·         Open the folder list view in FrontPage (View | Folder List)

·         With FrontPage still open, launch Windows® Explorer.

·         Navigate to the files you wish to copy to your web.

·         Drag and drop these files into your FrontPage web.

In both of the above methods, FrontPage will recognize the .mdb file extension of the Access database and prompt you to create a new connection for that database.  Go ahead and enter the database name and click “OK.”

You can then connect any form to that database using the methods described here.

Connecting Your Form to an External Database

You might find yourself in a situation where your database is hosted outside of your Web site.  Because of the power of the Internet and the ease of use offered by FrontPage 2003, you can connect to any database on the Internet from your Web as long as it is available on the Web and is ODBC compliant.

Before you connect to the database, you will need to determine the server name and passwords required to access your database.  The person in charge of the database will be able to provide you with the information necessary to make a connection.  An example of when this approach might make sense is when your site becomes very popular and its requirements outgrow the capabilities that Access offers.  So you might ask your Web site hosting company to set up a SQL Server™ database for you to use to store your important Web data.  When they do this, they will supply you with the server name, user name, and password necessary to connect to it from your forms in FrontPage.

Once you have figured out the path, login and password to the external database, connecting is simple:

·         Right click inside the form boundary (the dotted line) on the Web page with the form you wish to connect to the external database.

·         Select “Form Properties”.  This will open up the “Form Properties” dialog box.

·         Select the “Send to database” radio button.

·         Click the “Options” button in the lower left-hand corner of the Form Properties dialog.  This will open the “Options for Saving Results to Database” dialog.

·         Click on “Database Results” tab.

·         Click the “Add Connection…” button.  The Database tab of the Web Settings Dialog box will open.  Click the “Add” button to open up the “New Database Connection” dialog box seen below.






·         Clicking the “Advanced” button on the “New Database Connection” dialog box will open the “Advanced Connection Properties” dialog box (seen below).  Enter the Username and Password given to you by the database administrator and enter any additional parameters required through the dialog box interface.



Sending Form Results Via Email or to a Text File

If you don’t have or need database connectivity, you can send the information from your form to an email address or to a text file on your Web site.  An article on this process can be found online on the FrontPage 2003 Article entitled, “Collecting Sales Leads Online with Microsoft FrontPage 2003.”  The URL for this article is: http://office.microsoft.com/assistance/2000/fpSalesLeads.aspx.

Once You Are Connected

Congratulations!  You now know how to add a feedback form to your Web, save it as an ASP file, and configure the form to send the data it collects to a database that FrontPage 2003 either created or set up the connection for.  You can use these same steps to send the data collected by any form in a FrontPage Web to a database.

Inserting Database Results with the Database Results Wizard

At this point, you now have a database at your site able to receive user input.  This might satisfy your needs.  If not, you probably are looking for a way to present database information in your Web site.  In this section, you will learn how to use FrontPage to display the results of a database table in your browser.

Displaying form results is a little more detailed than sending form results to a database, but is still accomplished quickly and easily using the FrontPage 2003 interface.

To insert database results into your Web site using the Database Results Wizard, select Insert | Database | Results into the page you wish to add the results to.  Remember that all pages that interact with a database will need to be saved with the .ASP extension.

Step 1: Selecting the Database

The first obvious option you are given is to select the database you would like to get the results from.  The dialog box offers three choices.

The first choice is to connect to Northwind, the sample database provided by FrontPage.  Use this feature if you wish to experiment with database results without having to worry about database creation.

The second option is to use an existing database connection.  FrontPage 2003 remembers all of the database connections you’ve ever worked with in the Web site you are editing.  Your choice is probably in the drop down menu.  If this is the case, pick the database you want to connect to and select the Next button.

The final choice requires you to set up a connection that previously didn’t exist.  If you select that option and push the Create button, you will be given access to the Database tab of the Web settings dialog box.  From here, pushing the Add button will open the New Database Connection dialog box (pictured below) that will let you set up a connection to either a File or folder in the current Web, a System data source on web server, a network connection to database server or a custom definition.  Select the options suited for the task and your connection is established.





Step 2: Record Source

Because databases can contain great amounts of information, it is important to choose which parts of the database information you would like to display.  The second step asks for the Record Source, which is the table you’ll be pulling your data from.

If you built the database from FrontPage 2003, you will only have one choice.  If you are connected to a database with multiple tables, you will need to choose the one you wish to connect to.

Another option here is to create a custom query. If you know SQL (the Structured Query Language – not to be confused with SQL Server, the popular Microsoft Database Product) you can enter the appropriate SQL code and choose exactly what you want to view.  Information about Microsoft SQL Server and the SQL language can be found online at http://www.microsoft.com/sql/ .



Step 3: Selecting Fields

Once you have selected the Record Source (table) you wish to get your information from, it is time to choose the fields that you wish displayed in your Web page.  If you want to show all of the fields, select the next button.  If you wish to show the information in only certain fields, simply select the Edit List button and choose accordingly as seen below.



You will notice that there is a More Options button in the Step 3 dialog box.  This button will take you to another dialog box enabling you to choose more specific criteria for ordering for the data.  As seen in the screen below, you can both set up a filter to match specific criteria as well as set the ordering structure for the results.



Step 4: Formatting

Now that you know the database, table and fields you wish to show, the goal now is to determine how you would like to display the data.  The Database Wizard gives you the capability to either present your data in a Table or Column option.

The three check boxes in step 4 enable you to decide if you want to use a table border, expand the table to the width of the page and include a header row with the column labels.

Step 5: Grouping the Results

Finally it is a simple choice of grouping your results.  Results generated form databases can be long and overwhelming.  Luckily, FrontPage 2003 has a solution for that issue as well.  Step 5 gives you the opportunity to split the results into a fixed number of records per page.  The default is 5 records, but the choice is yours to make.

That’s It

Once you’ve gone through these five simple steps, the appropriate ASP code is written and your Web site reports accordingly.  You need to save your page as an ASP page (filename.asp).  You can view the Web pages from any browser, and every time your page is visited, an updated snapshot of the database contents is presented on the page.  You have integrated a database results with your FrontPage 2003 Web site.



Summary

The new database integration features found in FrontPage 2003 give you both the power to integrate database content into your Web site as well as program dynamic content to your site without spending weeks in a database class or learning complicated programming skills.  If you need to implement a complete database solution into your Web site, the new Database Interface Wizard can help you do just that.  If you need to implement elements of a previously existing database into your Web site, the tools provided by FrontPage 2003 can help you to do that as well.

You have taken the first steps towards moving from the position of a developer of static Web sites to that of an interactive programmer, all without having to know programming.  

Now that you understand database connectivity options and how they integrate easily and simply with FrontPage 2003, consider the options available to you:  You can publish an interactive address book for members of a club you belong to, you can enable your potential customers to populate your contacts database without you having to enter a thing, you can make inventory information made available online or create the first part of an e-commerce engine that takes orders directly from the customer.  You can also set up an entire Web-based database management solution without ever having to purchase a single database product.

Databases are exciting.  The power provided by FrontPage 2003 makes database integration simple.  The possibilities are endless, and they are yours to explore.











fpdb/index.mdb



No comments:

Post a Comment