Saivaneri Web Tutor
LTNS, isn’t it?. But we have got to know more in the meantime. This chapter explains How To Host FREE DATABASE ENABLED WEBSITE. Normally you would have to pay at least Rs.1000 per annum to add database support to a Linux server. For windows too. So the total cost of owning a website gets higher than ever. There are free solutions to this in the form of www.brinkster.com for Access based databases, or free FLAT FILE data basing solutions for LINUX servers.
We will see how to host on brinkster an access database. It’s really fast and simple. No ads, no fee, just pull the code below and eNjoY!.
The ASP (Active Server Pages) code to call a MS Access GUEST BOOK DATABASE:-
To test run the ASP scripts, you must have PWS (personal web server) for windows 98 loaded on your system. On a Windows XP machine IIS (Internet Information Server) is already installed on your system. You can start your local web server by typing your
http://machine name (in my case it is http://pasco)
Remember these URLs are running on LOCAL MACHINE only, so cannot by accessed on the WWW.
All local machine servers have a folder called C:\Inetpub\wwwroot. This is the folder where your htm. Html or asp pages are published. You can publish to your local server from Macromedia Dream weaver or MS FrontPage. Or you can directly go to the folder wwwroot and create a subfolder for your web site, and then do all these practice exercise as given in this chapter. You can name a folder called Tutorial so that our examples will run from there
To run the following code, copy the following ASP files and Database.mdb file to the C:\Inetpub\wwwroot\Tutorial folder. You can call the asp file now by typing http://localhost/database1.asp
This lesson requires that you have Microsoft Access installed on your system
Guest books allow your Web site visitors to leave behind information, such as their names, e-mail addresses, and comments. In this lesson, you perform the following tasks after creating an Access database:
· Example 1 Create an ASP page to connect to the database using only the ADO Connection object.
Create an Access Database
Create an Access database called GuestBook.mdb, and save it in x:\Inetpub\Wwwroot\Tutorial. Create a table in the database called GuestBook. Use the Create Table Using Design View option in Access to add the following fields and properties:
Create an ASP Page to Add Data to Your Access Database
Now that you have created a database, you can build an ASP page to connect to your database and read incoming data using Microsoft ActiveX® Data Objects (ADO). ADO is a collection of objects with methods and properties that can manipulate data in almost any type of database. (If you plan to use databases frequently, you should purchase a programmer's reference book for ADO. Only the most basic ADO code is illustrated in the following examples, enough to open, read in, and write to a database.)
The next two examples produce the same results; however, the first example uses only the Connection object, and the second example gives part of the job to the Command object, which is much more powerful. Compare both examples to see how the objects become connected together. After you are comfortable with the objects, use an ADO programmer's reference to experiment with more methods and properties.
To see an example of an ADO error in your ASP page, try browsing to the page after renaming your database, after entering a typing mistake in the connection string, or after making the database Read Only.
Example 1: Using Only the ADO Connection Object – The ASP SCRIPT
Copy and paste the following code in your text editor, and save the file as GuestBook1.asp in the x:\Inetpub\Wwwroot\Tutorial directory. View the example with your browser by typing http://localhost/Tutorial/GuestBook1.asp in the address bar.
see to that your database PATH is correctly mentioned in the script.
Now how to upload this file to www.brinkster.com ?
While registering be careful because the username and site name is to be same.
My site name is http://www26.brinkster.com/vkplexa/
Check with my site name by going to these URLS
after registering an account with brinkster, go to file manager, upload your ASP files to the root folder there, and upload database files to /db folder.
The working of ASP on the brinkster is slightly different so be careful to amend the ASP file on your local machine before uploading the file to the brinkster server.
AMENDMENTS TO BE DONE ON DATABASE.ASP FILE BEFORE UPLOAD TO BRINKSTER (RED COLORED TEXT IS THE ONLY AMENDMENTSALL OTHER TEXT ARE SAME)
NAME THIS FILE AS brinkguestbook.asp THEN UPLOAD TO YOUR SITE.
<%@ Language=VBScript %>
<title>Guest Book Using Connection Object Only</title>
<font face="MS Gothic">
<h2>Guest Book Using Connection Object Only</h2>
If Not Request.QueryString("Message") = "True" Then
'No information has been input yet, so provide the form.
<FORM NAME="GuestBook1" METHOD="GET" ACTION="brinkguestbook.asp">
<td><font face="MS Gothic">From:</td><td><INPUT TYPE="TEXT" NAME="From"></td>
<td><font face="MS Gothic">E-mail Address:</td><td><INPUT TYPE="TEXT" NAME="EmailAdd"></td>
<td><font face="MS Gothic">CC:</td><td><INPUT TYPE="TEXT" NAME="CC"></td>
<td><font face="MS Gothic">Subject:</td><td><INPUT TYPE="TEXT" NAME="Subject"></td>
Message:<br><TEXTAREA NAME="Memo" ROWS=6 COLS=70></TEXTAREA>
<INPUT TYPE="HIDDEN" NAME="Message" VALUE="True">
<INPUT TYPE="SUBMIT" VALUE="Submit Information">
dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
strTB1 = Server.HTMLEncode(Request.QueryString("From"))
strTB2 = Server.HTMLEncode(Request.QueryString("EMailAdd"))
strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
'use your site name
Set oConn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("\vkplexa\db\guestbook.mdb") & ";" & _
"Persist Security Info=False"
strCommand = "INSERT INTO GuestBook (FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
strCommand = strCommand & strTB1 & "','" & strTB2 & "','" & strTB3 & "','" & strTB4 & "','" & strMB1
strCommand = strCommand & "')"
Response.Write("Thank you! Your data has been added.")
DO THIS CHAPTER AT YOUR HOME AND ON THE SERVER. CALL ME TO VISIT IT. NEXT CHAPTER WE WILL SEE HOW TO SEARCH, VIEW, DELETE THE RECORDS IN THE DATABASE.