ASP Advanced Tutorial Ⅷ: Database version of the guest book

Source: Internet
Author: User

In the front we introduced the file version of the guest book, now we might as well imagine: if the message file inside a lot of messages, and you are anxious to find a message in one of them, then open the TXT message file, to a paragraph of the message records, you dare to guarantee that you will not faint on the spot? And the most annoying thing about the file book is far more than that, more irritating: for example, you have found the message you are looking for, and is not to delete it (of course, because the message is mercilessly on your face smear the reason for it), then the rest of you want to praise the words of friends, You will not be able to leave a message because you are deleting the message. Look, how sad it is! However, you do not need to sigh, although the message file can not be used for many people, but changed to a database to manage the message records, when you do delete the message, the visitor's message can be added in. Since the database guest book can be so considerate to your system, we now without further ado, immediately to uncover her true colors.
As for how to build their own database version of the guest book, we still through a step-by-step approach to explain it. To write a database version of the guest book, we can roughly take the following three steps to complete.
Step One: Use Access to create a datasheet that holds the message. (Of course, if you want to make your database work well in high demand, customer-server databases for high-quality Web applications, and can withstand rigorous testing in performance and reliability, you'd better use server-level databases such as SQL Server, Oracle, and so on. For databases that are not server-level, I recommend using the Chinese version of access to build. The data tables that are created with access are the. mdb suffix name, such as: Book0.mdb. )
Access has a very friendly interface, the operation is also very simple, I believe that smart readers, even if never used access, as long as the hands to try, also will be able to quickly on its crossbow drive freely, so I will not be here to repeat (of course, do not rule out a few lazy ingredients).
Step two: Designing a Web page for a message form is also indispensable. (such as: guestbook0.htm).
  
Step three: And to write the processing of the message of the ASP program. (We can copy the code below and save it as a manage0a.asp file.) )
<!--#include file= "Adovbs.inc"-->
' Invoke the Adovbs.inc file, the so-called Inc file is meant to include file, Adovbs.inc is the IIS/PWS provided by the files, the definition of ADO related constants, using the Inc file can make our program, increase readability, Easier to develop and maintain.
<% Function Sqlstr (data)
Sqlstr = "'" & Replace (data, "'", "" ") &" "
End Function
' Here's a sqlstr function that changes one single quotation mark in the data to two single quotes, and it's preceded by a single quote. The reason for this function is that the data entered by the surfer must be combined with the INSERT INTO command in the form of a single quotation mark, but if the data entered by the user contains single quotes, the ' entered data ' will produce an error. It is therefore correct that the data entered must be SQLSTR (switching single quotes into two single quotes).
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.