1. RS.OPEN SQL,CONN,A,B,C
2.
CONN.EXECUTE(SQL,RowsAffected,C)
Parameter meaning:
The value of SQL can be an SQL statement, table name, stored procedure name, or any string acceptable to the data provider. In order to improve performance, it is best to specify appropriate values for the C parameter. The optional parameter RowsAffected will return the number affected after the execution of the INSERT, UPDATE or DELETE query. These queries will return a closed Recordset object.
A SELECT query will return a RowsAffected value of -1 and return an open Recordset with one or more rows of content.
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.execute "update Table1 set Col1='123'",RowsAffected,&H0001
Response.Write RowsAffected&" Rows Affected"
Conn.close
Set Conn=Nothing
%>
A:
ADOPENFORWARDONLY(=0)
Read-only, and the current data record can only be moved downwards
ADOPENKEYSET(=1)
Read-only, the current data record can be moved freely
ADOPENDYNAMIC(=2)
Readable and writable, the current data record can be moved freely
ADOPENSTATIC(=3)
Readable and writable, current data records can be moved freely, new records can be seen
B:
ADLOCKREADONLY(=1)
The default lock type is that the recordset is read-only and records cannot be modified.
ADLOCKPESSIMISTIC(=2)
Pessimistic locking, when a record is modified, the data provider will try to lock the record to ensure that the record is successfully edited. As soon as editing begins, the record is locked.
ADLOCKOPTIMISTIC(=3)
Optimistic locking does not lock the record until the updated record is submitted using the Update method.
ADLOCKBATCHOPTIMISTIC(=4)
Batch optimistic locking allows multiple records to be modified, and the records are locked only after the UpdateBatch method is called.
When no records need to be modified, a read-only recordset should be used so that the provider does not need to do any detection.
For general use, optimistic locking is probably the best option, since records are only locked for a short period of time,
The data is updated during this time. This reduces resource usage.
C: (Specify SQL statement type)
ADCmdUnknown (= &H0008)
Unknown, it needs to be judged by the system, the speed is slow, it is the default value
ADCmdText (= &H0001)
Command statements such as SQL statements such as: Select * from Table1
ADCmdTable (= &H0002)
Query table name, for example: Table1
ADCmdStoredProc (= &H0004)
Stored procedure name
ADCmdFile (= &H0100)
The file name corresponding to the object type
ADCmdTableDirect (= &H0200)
It is the table name that can directly obtain the row content from the table.
conn.execute(sql)(0) is the value of the first field of the data set.