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 a proper value for the C parameter.
The optional parameter RowsAffected returns the number of values affected after the INSERT, UPDATE, or DELETE statement 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)
Read/write: The current data records can be freely moved.
ADOPENSTATIC (= 3)
Read/write: The current data record can be freely moved. 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: The record is locked only when an Update record is submitted using the Update method.
ADLOCKBATCHOPTIMISTIC (= 4)
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 option, because the record is locked for only a short period of time,
The data is updated during this period. This reduces resource usage.
C: (specify the SQL statement type)
ADCmdUnknown (= & H0008)
Unknown, which must be determined by the system. The speed is slow and the default value is used.
Ad1_text (= & H0001)
Command statements, such as SQL statements
For example, Select * from Table1
ADCmdTable (= & H0002)
The name of the queried table, for example, Table1.
ADCmdStoredProc (= & H0004)
Stored Procedure name
Ad1_file (= & H0100)
Object Name
ADCmdTableDirect (= & H0200)
Is the name of the table that can directly obtain the row content from the table.