Whether it is RS.OPEN SQL, Contn or Conn.execute (SQL) [SQL here is delete, update, insert], a closed record set will be returned after the execution is performed
RS.Oopen SQL, CONN: If SQL is delete, update, insert, it will return a closed record set. Do not come to a RS.Close during the use process. At the end of the file, write RS.Close
There are multiple record sets of RS1.Oopen SQL1, CONN, and the last closing record set: RS.Close RS1.Close
Conn.execute (SQL) If SQL is delete, update, insert will return a closed record set. Do not come to a RS.Close during the use process.
There can be multiple record sets of RS1.Oopen SQL1, CONN, and the last closing record set: RS.Close RS1.Close.
If SQL is update, insert, delete, you should use conn.execute (sql) or you can do not (SQL).
If SQL is a select statement, you should use set rs = conn.execute (SQL) parentheses must be omitted.
The call must be added with parentheses, and the call without the return value can be added without parentheses.
Note: Whether it is RS.OPEN SQL, CONN or Conn.execute (SQL) [SQL here is delete, update, insert], will return a closed record set after execution
In other words, if SQL is inserted, updated, and deleted statements, then the RS in Set RS = const.execute (SQL) is meaningless.
1.conn.execute
sql = select * from admin where username = 'xiaozhu'
set rs = const.execute (SQL)
Automatically close the record set after executing
In the end, just close the connection
conn.close
set conn = nothing
2.RS.Oopen
set rs = server.createObject (Adodb.oldSet)
sql = select * from admin where username = 'xiaozhu'
RS.Oopen SQL, CONN, 1,1
You can set some parameters by yourself, that is, the movement of locking and a campaign
Finally, close the record set and connection
RS.Close
set rs = Nothing
conn.close
set conn = nothing
3.Comand.execute
sql = select * from admin where username = 'xiaozhu'
set rs = Command.execute (SQL)
************************************************* *************************************
1.
Set RS = const.execute (if it is a select statement) obtained by the RS.RCORDCOUNT = -1
RS.Oopen SQL, CONN (SQL is a select state
2.
RS.Oopen is to open the database conn.execute to execute the SQL instruction
set rs = const.execute (insert, update, delete) Return a closed record set
set rs = const.execute (select) Return a record set that is not closed
3..
Conn.execute (SQL, ROWSAFFECTD, C)
Parameter meaning:
The value of SQL can be SQL statements, table names, storage procedures, or any accepted string that data providers can accept. In order to improve performance, it is best to specify the appropriate value for the C parameter
Optional parameter ROWSFFECTED will return the number of influences after the execution of Insert, Update or Delete. These queries return a closed recordset object.
A SELECT query will return the ROWSAFFECTD value to -1 and return the RECORDSET with one or multi-line content.
4. 4..
Conn.execute SQL is suitable for use when it does not need to return to the RECORDSET object, such as the following code:
sql = delete from ennews where id = & cstr (ID)
conn.execute sql
If you need to return to the RecordSet object, use the following code:
SQL = Select from Enews where ID = & cstr (ID)
set rs = const.execute (SQL)
If you remove the EXECUTE (SQL) (SET RS = Conn.execute SQL), it will prompt the statement that the statement is not over. I looked at the grammar format and found that there are two formats. The details are as follows: below:
Format 1: Connection object name.execute (SQL instruction).
Format 2: Connection object name .execute.
It can be seen from the above format that the SQL instructions behind Execute are included in brackets, but in fact, if the operations such as deletion or modification are performed, it is not necessary to include the SQL instruction in the brackets and can be executed correctly. What is it? The SQL instruction must be included in the brackets, otherwise there will be an error. After seeing all the ASP tutorial at hand, I did not mention this problem. But don't just talk about the rules of grammar, I hope to get the correct answer, thank you.