SoFunction
Updated on 2025-04-08

Several common mistakes made by ASP beginners (ZT)

1. Open again before the record set is closed:
------------------------------------
sql="select * from test"
sql,conn,1,1
if not then
dim myName
myName=rs("name")
end if
sql="select * from myBook"
sql,conn,1,1
-------------------------------------
Solution: Close before the second time
or
set rs1=
sql,conn,1,1

2. Use SQL keywords to make table names or field names
-------------------------------------
sql="select * from user"
sql,conn,1,1
-------------------------------------
User is SQL keyword
Solution: Change to
sql="select * from [user]"


3. Use locking to update
-------------------------------------
sql="select * from [user]"
sql,conn,1,1

or
rs("userName")="aa"

-------------------------------------
The current record set is open to read-only
solve:
Change to
sql,conn,1,3

4. The comparison field value used in the query statement does not match the field type
-----------------------------------------
sql="select * from [user] where id='" & myID & "'"
sql,conn,1,1
-----------------------------------------
Assuming that the design ID in the table is numeric, then an error occurs sometimes.
solve:
sql="select * from [user] where select * from [user] where select * from [user] where select * from [user] where aa"
Then sql will become
sql="select * from [user] where id=aa"
solve:
Add in front
if isnumeric(myID)=false then error message

This can also effectively prevent sql injection vulnerability attacks.

7. The NTFS permissions of the directory where the database file resides cannot be updated. Database or object is read-only" error.
illustrate:
The WIN2K system continues the NTFS permissions of the WINNT system.
There are default security settings for folders in the system.
The default user of the system when accessing WWW via HTTP is iusr_computer name user, which belongs to the guest group.
When accessed via HTTP, you can modify the data by ASP or JSP, or PHP or .NET programs:
for example:
When opening a certain article, the program sets the number of reads of the article = original number of reads + 1
implement
("update arts set clicks=clicks+1 where id=n")
When a statement is performed, an error occurs if the user does not have write permissions to the database.
Solution:
Find the directory where the database is located
Right click "Properties" Security tab" Set iusr_Computer name User's write permission (of course, it can also be everyone)