On the ASP programming ideas and correction Author: Hu Hongxiang

zhaozj2021-02-16  59

For beginners programming with ASP technology, there is no first feeling, and the author has had such an experience.

After some "hardship", you will find inspiration. Some experiences accumulated in my programming, proposed to be cultivated, dedicated to the reader.

1 First learn some examples of examples.

After receiving the task, don't blindly urgently write code, but first look at the example of successful people.

Then modify or imitate debugging on it, which will speed up your familiarity.

For example, there is often such an example in the textbook of ASP programming, that is, the statement of the current time of the system: <% = now ()%>,

Don't look at this simple statement, but it contains the programming ideas and formats of the ASP, which will give you a great help from the work behind you. For example,

Test if the IIS (Internet Information Server) Web Server works normally, and the test of one statement is sufficient.

2 After installing ODBC on Windows NT, you want to test and start programming test after testing and background databases.

Maybe you don't understand the topic, I explain here: For example, the background database is Oracle,

Then first install SQL * NET (or Net 8) on NT Sever, then configure ODBC, determine and connect to Oracle databases.

You can use SQL * Plus test, you have to select the same character set as the Oracle database.

This job should be done in the registry. Finally, after the ODBC is tested and the Oracle database is connected.

Note that the WEB Server to the background database is completed,

The programming work will be started next. Conversely, if you first program, then do ODBC's work, then you can't debug the program correct, it may greatly reduce programming efficiency.

In the ODBC configuration, you want to select Microsoft Odbc for Oracle, do not select Oracle ODBC Driver, otherwise you cannot connect with the database.

In the ASP program, and the statement connected to the database is relatively fixed, for example, as follows:

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 connections.

O7PEOPLE is a username of Oracle, and people PEOPLEPD is the password of the user O7PEOPLE.

3 Record the error information to find the error correction.

In programming, during debugging, it is an error, the error correction cycle process, but the time is long.

Will find some rules, the efficiency of the rule of the error will be greatly improved.

3.1 Error Information:

Microsoft OLE DB Provider for ODBC Drivers Errors '80040e14'

[Microsoft] [ODBC Driver for Oracle] [Oracle] ORA-00933: SQL Command Not Properly Ended

/Default.asp, line 781

This error is generally in executing conn.execute ("SQL statement"),

The defined "SQL statement" has a problem, check this statement, you can find problems, such as the date format is wrong, and so on.

Zhezhong3.2 error message:

Adodb.field error '800A0bcd'

One of BOF or EOF is "true", or the current record has been deleted, but the application requires the current record.

/LZJSBLR.ASP, line 123

This error generally occurs during the process of performing the following statements:

SET RS = Conn.execute ("SQL Statement")

Varnum1 = rs (0)

Rs.close

The value RS (0) is meaningless or meaningless, but also check the correctness of the "SQL statement".

3.3 Error Information:

Microsoft VBScript compiler error error '800A0409'

Unfairted string often

/POPLE/default.asp, line 86

INSERT_SQL = INSERT_SQL & DWDM & ", '" & D1 & ",

'"& T1 &",' "& t2 &" ',

-------------------------------------------------- ------------------------ ^

The second item is also on the definition of the SQL statement, check the pairing of quotation marks, single quotes, etc.

4 Next is a browser-based online user registration process,

The author used some skills to dedicate it to interested readers.

......

<

<% 'And database connections

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%>

<%

Rs.movenext

Loop

Rs.close

%>

<%

'Defining 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 conditions (trigger conditions)

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 Convert to Oracle Identification 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 &", '"& t4 &" "" "

SQL_INSERT = SQL_INSERT & T5 & "','" & D2 & "','" & CSRQ & ",

'"& T7 &",' "& t8 &", '"& sqrq &"', '"

SQL_INSERT = SQL_INSERT & T10 & ")"

'Take information

SET LFMC_R4 = Conn.execute (SQL_INSERT)

"After the information is completed, the screen information is initialized

Call Reset ()

END IF

%>

转载请注明原文地址:https://www.9cbs.com/read-15403.html

New Post(0)