ASP Personal Hands-on Guide

Source: Internet
Author: User
Tags contains odbc one table table name access database microsoft access database oracle database wysiwyg html editor
ASP is a good thing, its strong interaction ability and data processing ability makes it become the favorite of commercial website. However, the design and debugging of ASP programs is not easy, just high-end server +windows NT operating system +iis servers +sql Server database system configuration is not our individual users can have access to. Is the ASP really not with us these individual users? Do we have to have such a luxurious hardware and software environment to embark on the study of the ASP's road?
After the author's efforts, finally using some commonly used software to configure a full-featured ASP development debugging environment, and in this developed a number of small systems.
First, hardware configuration
pⅲ450 dual cpu+1g memory +10g SCSI hard drives above, please don't be afraid, this is just a standard configuration for 肳 indows NT Web server. Of course, we don't need such a configuration, we just want a machine that can run Windows 98 smoothly. What You are using p100+16m memory +540m hard drive, then go to a subordinate. )
Second, the software configuration
First of all, we need to install Windows 98, which I believe everyone will be. (What, you can't even this, that ASP also need not learn, advanced Literacy Class bar.) )
Second, we need to install personal Web Server (PWS), you ask where it can be found, too simple, in the Windows 98 CD-ROM, there is a directory called "Add-ones", which has a directory named "PWS", The SETUP.EXE on the inside of the operation began to install (Figure 1).
When Setup runs to the minimum, typical, custom installation selection, select Custom, then Personal Web Server (PWS), and then press show subcomponents. Then select document, press Show subcomponents, and then select Active Server Page. This component will install a number of documents, including ASP tutorials, VBScript tutorials, and JScript tutorials, to the benefit of future development. When you have finished selecting, press OK and then press next to start setting up the directory where the WWW service document is stored, the default is "C:inetpubwwwroot", and it is recommended that you do not change it. The "MTS installation Folder" is then set and the default is "C:Program Filesmts" and is not recommended for change. After pressing "Next" again, the most critical installation begins, please be patient, this configuration of PWS is about 90 trillion (Figure 2), it may take a considerable time.
After the installation is complete, run the Office 97 installer again. (What, this is not!) If you have SQL, oracal, infomix these large databases that will do, but it seems a bit overqualified. Select Custom Install, and then in the Components list, select Microsoft Access and Data access (users who have used VB please don't make a mistake, this data Access is just a driver and a tool for connecting to databases in various data formats, is not the VB in the Small database software).
So far, need to install the software and all installed, but not too early, now your ASP has not been able to deal with the database, (what, you do not need to deal with the database, then you use ASP why, on the interactive Java script is not worse than the ASP, but also learn a lot?) Next, we also need to do both the database creation and ODBC setup steps.

Third, database creation
A good program = data + algorithm. For a database program, the database is essential. We'll create one with access below.
1) please start Access. Because here we are just giving the reader a demonstration, so you create a very simple database that includes only one table and only one field in the table (for the concepts of database, table, field, check out a good database book or help this document for access).
2 Select "Empty Database" in "New Database" and press "OK" and enter the file name of the database (for c:test in this demonstration). MDB) and press "create".
3 Select "Table" and press "new".
4 Enter a field with the field name "name", the data format is "text" and the field size is "10".
5 Close the window and ask you in the pop-up window "Do you want to save changes to the ' Table 1 ' design?" When selected, and set table name to Table1.
6 will then pop up the window to tell you that you have not created a "primary key", "yes" or "no", "yes" or "no" relationship is not very small, choose one randomly.
7 to this, a very basic database will be completed, of course, in order to facilitate our testing work, please reactivate the "table1" just established, and enter some data.

Four, set up ODBC
Before setting up ODBC, it is necessary to explain the concept of ODBC to the reader, which is conducive to understanding the following content. ODBC (open Databases connectivity Open Database interconnection) is an industry standard introduced by Microsoft, an open, vendor-independent API application interface that enables access to a variety of personal computers, minicomputer, and host systems across platforms. As an industry standard, the vast majority of database vendors, most applications and tool software vendors provide ODBC interfaces or provide ODBC support for their products, including commonly used SQL Servers, oracal, Informix, and so on.
All we have to do is to provide a way to locate, identify, and communicate with the database before creating the database script. The database driver uses data Source Name (DSN) to locate and identify specific ODBC-compliant databases and pass information from the WEB application to the database. Typically, a DSN contains database configuration, user security, and location information, and you can get a table in a Windows NT registry key or a text file.
With ODBC, we can select the type of DSN you want to create: User, System, or file. System DSN allows all users to log on to a specific server to access the database, and the user DSN uses the appropriate security credentials to restrict the database to a specific user's connection. File DSNs are used to get tables from text files, provide access to multiple users, and can be easily transferred from one server to another by replicating DSN files. In this example, we use a file DSN. Of course, because you use a different database, the specific settings are slightly different, where we only describe access, SQL Server, oracal three database ODBC settings.
First on the Windows Start menu, open Control Panel, double-click the ODBC icon, and then select the File DSN property page, click Add, select the database driver, and then click Next. Follow the instructions later to configure the DSN that applies to your database software.
1 Configure the file DSN for the Microsoft Access database
In the Create New Data Source dialog box, select Microsoft Access Driver from the list box, and then click Next.
Type your DSN file name (use test in this example), and then click Next.
Click Finish to create the data source.
In the ODBC Microsoft Access 97 Setup dialog box, click Select. Select the Microsoft Access database file (*.mdb), and then click OK.
2 Configure SQL Server database file DSN
In the Create New Data Source dialog box, select SQL Server from the list box, and then click Next.
Type the name of the DSN file (use test in this example), and then click Next.
Click Finish to create the data source.
Type the name, login ID, and password of the server that is running the SQL Service program.
In the Create a new data source for SQL Server dialog box, type the name of the server that contains the SQL Server database in the Server list box, and then click Next.
Select how you want to verify your login ID.
If you want to select SQL Server Authentication, enter a login ID and password, and then click Next.
In the Create new data source for SQL Server dialog box, set the default database, the driver for the stored procedure settings, and the ANSI identity, and then click Next. (To get more information, click Help.) )
In the dialog box (also named "Create a new data source for SQL Server"), select a character conversion method, and then click Next. (For more information, click Help.) )
In the next dialog box (also named "Create a new data source for SQL Server"), select the login settings.
3 Configure Oracle database file DSN
First, make sure that the Oracle user software is correctly installed on the computer on which you want to create the DSN. For more information, contact your server administrator or consult your database software documentation.
In the Create New Data Source dialog box, select Microsoft ODBC for Oracle from the list box, and then click Next.
Type the name of the DSN file (use test in this example), and then click Next.
Click Finish to create the data source.
Enter the user name, password, and server name, and then click OK.
Well, after properly setting up ODBC, the most exciting moment: the preparation of ASP program.

V. Compiling of ASP Program
Generally speaking, people like to use WYSIWYG HTML Editor to edit HTML documents, but all WYSIWYG HTML editors are not very good for ASP support, so we recommend that you use WYSIWYG HTML editor to complete all the fixed HTML statements, Then use the Plain text editor (the Notepad that came with Windows) to join the ASP program. In this example, the task that an ASP program completes is simply to open the database to read all the data from the Name field in the Table1 table and output it to the browser.
Specific procedure: c:inetpubwwwrootdefault.asp
<%@ Language=vbscript%>
<%
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Test"
Set Rs=conn.execute ("SELECT * FROM table1")
Do as not rs.eof
Response.Write rs ("name") + "

Rs.movenext
Loop
Rs.close
Conn.close
%>
The program is over here and it's not quick to input it into your computer and try it.




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.