Home >Backend Development >PHP Tutorial >Novice School: Detailed explanation of rs.open and conn.execute_PHP Tutorial
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. To improve performance, it is best to specify appropriate values for the C parameters 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. 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) Can be read and written, the current data record can be moved freely, and new records can be seen B: ADLOCKREADONLY(=1) Default lock type, 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, the record is not locked 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, 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 For example: Select * from Table1 ADCmdTable (= &H0002) Query table name, for example: Table1 ADCmdStoredProc (= &H0004) Store procedure name ADCmdFile (= &H0100) The file name corresponding to the object type ADCmdTableDirect (= &H0200) 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
<ccid_code></ccid_code><%
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&" 行受到影响"
Conn.close
Set Conn=Nothing
%>