Talking about the thinking and correcting of ASP programming

Source: Internet
Author: User
Tags date define character set commit current time odbc reset oracle database
Programming for the use of ASP technology for beginners, it is the first feeling, I have had such a experience. After a "ordeal", you'll find inspiration. Now I have accumulated some experience in programming, to the cost of the text, dedicated to the reader.
1 First of all to learn some examples of programs.

After receiving the task, do not blindly rush to write code, but first look at the success of others, and then modify or imitate debugging, this will speed up your familiar speed. For example, the textbook on ASP programming often has such an example, that is, the statement showing the current time of the system: <%=now ()%>, don't look at such a simple statement, inside but contains the ASP's programming ideas and format, will give you the work behind the great help. For example, to test whether the IIS (Internet Information Server) WEB server is working properly, it is sufficient to test with one of the above statements.

2 after installing ODBC on Windows NT, test and then start the programming test after you have actually communicated with the background database.
Perhaps you do not understand the meaning of the topic, I explained here: for example, the background database is Oracle, then on the NT sever first to install Sql*net (or NET 8), and then configure ODBC to determine and Oracle database connectivity, you can use Sql*plus test, Also select the same character set as the Oracle database, which will be done in the registry. Finally, after the ODBC inside test and Oracle database connectivity, the Web SERVER to the back of the database end of the work is completed, and then start programming work. Conversely, if you first program, and then do ODBC work, then you can not debug the program is correct, may greatly reduce the efficiency of programming. To select Microsoft ODBC for Oracle in the ODBC configuration, do not select Oracle ODBC DRIVER, or you cannot establish a connection with the database.

In an ASP program, the statements that are 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, PEOPLEPD is the user o7people password.
3 Record the error message, look for error correction law.
In the programming, debugging process, is an error, error correction of the cycle, but a long time, will find some rules, the efficiency of the elimination of errors 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, line 781
This error typically occurs when you perform a conn.execute ("SQL statement") operation, the defined "SQL statement" has a problem, check this statement to find the problem, such as the date format is not correct, and so on.
Zhezhong
3. 2 Error message:
ADODB. Field error ' 800A0BCD '
One of the BOF or EOF is "true", or the current record has been deleted, but the application requires that the current record be manipulated.
/lzjsblr.asp, line 123
This error generally occurs during the execution of the following statement:
Set RS = Conn.execute ("SQL statement")
Varnum1=rs (0)
Rs. Close
The value RS (0) is meaningless or meaningless, and the correctness of the "SQL statement" is checked.
3. 3 Error message:
Microsoft VBScript Compiler error ' 800a0409 '
String constants that are not ended
/people/default.asp, line 86
Insert_sql = insert_sql & DWDM & ", ' & D1 &" ', ' "& T1 &" ', ' "& T2 &",
--------------------------------------------------------------------------^
The minor error is also defined on the SQL statement, checking the pairing of quotes, single quotes, and so on.
4 Below is a browser-based online user registration process, the author in the use of some skills, dedicated to interested readers.
......
<
<% ' and database connection
Set Conn = Server.CreateObject ("ADODB. Connection ")
Conn.Open "Odbclink", "O7people", "PEOPLEPD"
' Put the selected data into the selection box
Set RS = Conn.execute ("Select DWMC from Tab_dw to DWDM")
%>
<% do, 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 the information
Sub Reset ()
D1 = ""
......
T9 = Date ()
T10 = ""
End Sub
%>
<%
Call Reset ()
%>
<%
' Information submission condition (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")
......
' Date data converted to Oracle-recognized format
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 &am P "', '" & T4 & "', '"
Sql_insert = Sql_insert &T5& ', ' & D2 & ', ' & Csrq & ', ' & T7 & ', ' & T8 & ' ', ' & Sqrq & ', ' '
Sql_insert = Sql_insert & T10 & "')"
' Storing the information
Set LFMC_R4 = Conn.execute (Sql_insert)
' After the information is submitted, initialize the screen information
Call Reset ()
End If
%>



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.