Introduction to ASP programming ideas and Error Correction

Source: Internet
Author: User

For beginners who use ASP technology to program, it is the first thing they have ever experienced. After some hardships, you will find inspiration. I will present some of my accumulated experience in programming to the readers.

1 first, we need to learn some examples.

After receiving a task, do not blindly rush to write code. Instead, you should first take a look at the successful examples of others, and then modify or simulate debugging on it, which will speed up your familiarity. For example, a textbook on ASP programming often displays a statement that displays the current time of the system: <% = now () %>. Don't look at such a simple statement, it contains ASP programming ideas and formats, which will greatly help your subsequent work. For example, it is enough to test whether the IIS (Internet Information Server) Web server works normally with the preceding statement.

2. After ODBC is installed on Windows NT, you must test the connectivity with the background database before starting the programming test.
You may not understand the meaning of the question. Here I will explain: for example, if the background database is Oracle, you must first Install SQL * Net (or net 8) on the NT Sever ), then configure ODBC to connect to the Oracle database. You can use SQL * Plus for testing and select the same character set as the Oracle database. This should be done in the registry. Finally, after testing the connectivity with the Oracle database in ODBC, it means that the work from the Web server to the back-end database is complete, and then start programming. In turn, if you program the program first and then do ODBC work, then you cannot debug the program correctly or not, which may greatly reduce the programming efficiency. In ODBC configuration, select Microsoft ODBC for Oracle. Do not select Oracle ODBC driver. Otherwise, you cannot contact the database.

In the ASP program, the statements connected to the database are relatively fixed, for example:
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "odbclink", "o7people", "peoplepd"
Here, odbclink is the name of the data source, which can be said to be the definition of ODBC and database connection. o7people is a user name of Oracle and peoplepd is the password of user o7people.
3. Record the error information to find the error correction rule.
It is a loop of errors and Error Correction in programming and debugging. However, after a long time, some rules will be found and the efficiency of error elimination will be greatly improved.
3.1 error message:
Microsoft ole db provider for ODBC drivers error '80040e14'
[Microsoft] [ODBC driver for Oracle] [Oracle] ORA-00933: SQL command not properly ended
/Default. asp, row 781
This error is generally executed in conn. execute ("SQL statement") operation, the defined "SQL statement" has a problem, check this statement to find problems, such as incorrect date format, and so on.
Zhezhong
3.2 error message:
ADODB. Field error '800a0bcd'
Either BOF or EOF is "true", or the current record has been deleted, but the application requires that the current record be operated.
/Lzjsblr. asp, row 123
This error occurs generally when the following statements are executed:
Set rs = conn. Execute ("SQL statement ")
Varnum1 = RS (0)
Rs. Close
The retrieved value Rs (0) is meaningless or meaningless, and the correctness of the "SQL statement" must be checked.
3.3 error message:
Microsoft VBScript compiler error '800a0409'
Unended String constant
/People/default. asp, row 86
Insert_ SQL = insert_ SQL & DWDM & ", '" & D1 & "', '" & T1 & "', '" & T2 &"',
-------------------------------------------------------------------------- ^
An item error also occurs in the definition of an SQL statement. Check matching conditions such as quotation marks and single quotation marks.
4. The following is a browser-based online user registration program. I have used some skills to offer them to interested readers.
<HTML>
<Head>
......
<
<% 'Connect to the database
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "odbclink", "o7people", "peoplepd"
'Put the selected data in the selection box.
Set rs = conn. Execute ("select dwmc from tab_dw order by DWDM ")
%>
<% Do while not Rs. EOF %> <option> <% = RS (0) %> </option>
<%
Rs. movenext
Loop
Rs. Close
%>
<%
'Define variables
Dim D1, D2, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, csrq, sqrq
'Event trigger button
B1 = "commit"
B2 = "return"
%>
<%
'Initialize Information
Sub reset ()
D1 = ""
......
T9 = Date ()
T10 = ""
End sub
%>
<%
Call reset ()
%>
<%
'Condition for information submission (trigger condition)
If request ("B1") = "commit" then'save button
D1 = request ("d1 ")
Set dwdm_rs = conn. Execute ("select DWDM from table_dw where dwmc = '" & D1 &"'")
DWDM = dwdm_rs (0)
Dwdm_rs.close
D2 = request ("D2 ")
......
'Convert date data to the format recognized by Oracle
Csrq = Day (T6) & "-" & month_array (month (T6) & "-" & year (T6)
Sqrq = Day (T9) & "-" & month_array (month (T9) & "-" & year (T9)
'Define SQL statements
SQL _insert = "insert into peopleuser (DWDM, dwmc, sjks, Tele, address, zipcode, XM, XB, csrq, peoplename, peoplepd, sqsj, Bz) values ('"
SQL _insert = SQL _insert & DWDM & "','" & D1 & "','" & T1 & "','" & T2 &"', '"& T3 &"', '"& T4 &"','"
SQL _insert = SQL _insert & T5 & "','" & D2 & "','" & csrq & "','" & T7 &"', '"& T8 &"', '"& sqrq &"','"
SQL _insert = SQL _insert & T10 &"')"
'Store information into the database
Set lfmc_r4 = conn. Execute (SQL _insert)
'After the information is submitted, initialize the screen information
Call reset ()
End if
%>
......

 

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.