1. Enable record set again before it is disabled:
------------------------------------
SQL = "select * from test"
Rs. Open SQL, Conn, 1, 1
If not Rs. EOF then
Dim myname
Myname = RS ("name ")
End if
SQL = "select * From mybook"
Rs. Open SQL, Conn, 1, 1
-------------------------------------
Solution: Close Rs. close before the second Rs. Open.
Or
Set RS1 = server. Createobject
Rs1.open SQL, Conn, 1, 1
2. Use the SQL keyword for the table name or field name
-------------------------------------
SQL = "select * from user"
Rs. Open SQL, Conn, 1, 1
-------------------------------------
User is the SQL keyword
Solution: change
SQL = "select * from [user]"
3. Use the locking method for update.
-------------------------------------
SQL = "select * from [user]"
Rs. Open SQL, Conn, 1, 1
Rs. addnew
Or
RS ("username") = "AA"
Rs. Update
-------------------------------------
The current record set is opened in read-only mode.
Solution:
Change
Rs. Open SQL, Conn, 1, 3
4. The comparison field values used in the query statement do not match the field type
-----------------------------------------
SQL = "select * from [user] Where id =" & myid &""
Rs. Open SQL, Conn, 1, 1
-----------------------------------------
Assume that the table is designed with the ID as a number, so there are some errors.
Solution:
SQL = "select * from [user] Where id =" & myid
5. An error occurred while checking the variable value.
-----------------------------------------
SQL = "select * from [user] Where id =" & myid
Rs. Open SQL, Conn, 1, 1
-----------------------------------------
Assume that the value of the myid variable is null, then the SQL statement becomes
SQL = "select * from [user] Where id ="
Solution:
Add
If isnull (myid) then error prompt
6. An error occurred while checking the variable value type.
-----------------------------------------
SQL = "select * from [user] Where id =" & myid
Rs. Open SQL, Conn, 1, 1
-----------------------------------------
Assume that the ID is numeric, and the value of myid is not null but a character. For example, myid is "AA"
Then SQL will become
SQL = "select * from [user] Where id = AA"
Solution:
Add
If isnumeric (myid) = false then error prompt
This can also effectively prevent SQL injection attacks.
7. data cannot be updated because of the NTFS permission in the directory where the database files are located. Database or object is read-only "error.
Note:
Wi