Conn.exe cute ("select ID, title, content from document where id = 1") (0) Get ID
Conn.exe cute ("select ID, title, content from document where id = 1") (1) obtain the title
Conn.exe cute ("select ID, title, content from document where id = 1") (2) retrieve content
T = conn.exe cute (SQL) (0)
Equivalent
Set rs = conn.exe cute (SQL)
T = RS (0)
(1) wzcount = conn.exe cute ("select count (ID) from 'table1'", 0, 1) (0)
What do the two parameters after execute mean? What does the last 0 mean?
(2) Set conn = server. Createobject ("ADODB. Connection ")
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open rssql, Conn, 1, 1, & h0001
What is the last & h0001?
Answer:
1. Rs. Open SQL, Conn, a, B, c
2. Conn. Execute (SQL, rowsaffected, c)
Parameter description: The SQL value can be an SQL statement, table name, stored procedure name, or any string accepted by the data provider.
To improve performance, it is best to specify the appropriate value for the c parameter. The optional parameter rowsaffected will return the number of affected values after the insert, update, or delete query is executed. These queries return a closed recordset object.
A SELECT query returns an open recordset with a rowsaffected value of-1 and one or more rows.
Ex:
<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "provider = sqloledb; Password = Xiaolu; user id = sa; database = test; Data Source = 127.0.0.1"
Conn.exe cute "Update Table1 set col1 = '000000'", rowsaffected, & h0001
Response. Write rowsaffected & "the row is affected"
Conn. Close
Set conn = nothing
%>
A: adopenforwardonly (= 0) read-only, and the current data record can only be moved down
Adopenkeyset (= 1) read-only, the current data records can be freely moved
Adopendynamic (= 2) can be read and written, and the current data records can be freely moved
Adopenstatic (= 3) can be read and written. The current data record can be moved freely. You can see the new record.
B: adlockreadonly (= 1) default lock type. The record set is read-only and cannot be modified.
Adlockpessimistic (= 2) pessimistic locking. When a record is modified, the data provider attempts to lock the record to ensure that the record is edited successfully. You only need to edit the record at the beginning, and lock the record immediately.
Adlockoptimistic (= 3) Optimistic Locking is performed until the update record is submitted using the update method.
Adlockbatchoptimistic (= 4) supports Optimistic Locking in batches. Multiple records can be modified. Records are locked only after the updatebatch method is called.
When no record needs to be modified, the read-only record set should be used, so that the provider does not need to perform any detection. For general use, Optimistic Locking may be the best choice, because the record is locked for only a short period of time, and the data is updated during this period of time. This reduces resource usage.
C: (specify the SQL statement type)
Adcmdunknown (= & h0008) is unknown and must be determined by the system. It is slow and the default value is
Adcmdtext (= & h0001) command statements such as SQL statements such as: Select * From Table1
The name of the table queried by adcmdtable (= & h0002), for example, Table1.
Adcmdstoredproc (= & h0004) stored procedure name
Ad1_file (= & h0100) object type file name
Adcmdtabledirect (= & h0200) is the name of the table that can directly obtain the row content from the table.