Several mistakes that ASP beginners often make

Source: Internet
Author: User
Tags numeric table name ntfs permissions
Beginner | Error 1: Open the recordset before closing it again.
------------------------------------
Sql= "Select*fromtest"
rs.opensql,conn,1,1
Ifnotrs.eofthen
Dimmyname
Myname=rs ("name")
endif
Sql= "Select*frommybook"
rs.opensql,conn,1,1
-------------------------------------
Resolve: Close Rs.close before rs.open the second time
Or
Setrs1=server.createobject
rs1.opensql,conn,1,1

2, use SQL keyword to do table name or field name
-------------------------------------
Sql= "Select*fromuser"
rs.opensql,conn,1,1
-------------------------------------
User is the SQL keyword
Resolution: Change to
Sql= "Select*from[user]"


3, with the lock way to update
-------------------------------------
Sql= "Select*from[user]"
rs.opensql,conn,1,1
Rs.addnew
Or
RS ("userName") = "AA"
Rs.update
-------------------------------------
The current recordset is open in read-only mode
Solve:
To
rs.opensql,conn,1,3

4, the Contrast field value used in the query statement does not match the field type
-----------------------------------------
Sql= "select*from[user]whereid=" &myID& ""
rs.opensql,conn,1,1
-----------------------------------------
Suppose that the design ID in the table is a numeric type, then an error occurs.
Solve:
Sql= "Select*from[user]whereid=" &myid

5, error not checking variable value
-----------------------------------------
Sql= "Select*from[user]whereid=" &myid
rs.opensql,conn,1,1
-----------------------------------------
Assuming the myID variable is null at this time, then SQL becomes
Sql= "Select*from[user]whereid="
Solve:
Add in front
Ifisnull (MyID) then error prompt

6, error not checking variable value type
-----------------------------------------
Sql= "Select*from[user]whereid=" &myid
rs.opensql,conn,1,1
-----------------------------------------
Assuming the ID is numeric, the myID variable is not NULL at this time, but is a character, such as myID at this time as "AA"
Then SQL will become
Sql= "Select*from[user]whereid=aa"
Solve:
Add in front
Ifisnumeric (MyID) =falsethen error prompt

This can also be an effective way to prevent sqlinjection vulnerabilities.

7, cannot be updated due to NTFS permissions on the directory where the database files reside. Database or object is read-only error.
Description
The Win2K system extends NTFS permissions on the WINNT system.
There are default security settings for folders in the system.
The system default user for WWW access through HTTP is the IUSR_ computer name user, which belongs to the guest group.
When accessed over HTTP, you can modify the data either by ASP or JSP, or by PHP or. NET programs:
Like what:
When opening an article, the program set, the article read the number of times = original reading +1
Perform
Conn.execute ("Updateartssetclicks=clicks+1whereid=n")
Statement, an error occurs if the IUSR_ computer name user does not have write access to the database.
Workaround:
Locate the directory where the database resides
Right Key Properties Security tab set the Write permission for the IUSR_ computer name (or everyone, of course)

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.