บทช่วยสอน ASP

ASP HOME

กวดวิชา WP

แนะนำหน้าเว็บ มีดโกนหน้าเว็บ เค้าโครงหน้าเว็บ โฟลเดอร์หน้าเว็บ หน้าเว็บทั่วโลก แบบฟอร์มหน้าเว็บ วัตถุหน้าเว็บ ไฟล์หน้าเว็บ ฐานข้อมูลหน้าเว็บ ผู้ช่วยหน้าเว็บ หน้าเว็บ WebGrid แผนภูมิหน้าเว็บ อีเมลหน้าเว็บ ความปลอดภัยของหน้าเว็บ เผยแพร่หน้าเว็บ ตัวอย่างหน้าเว็บ ชั้นเรียนของหน้าเว็บ

มีดโกน ASP.NET

แนะนำมีดโกน มีดโกนไวยากรณ์ มีดโกน C# ตัวแปร มีดโกน C# ลูป มีดโกน C# Logic ตัวแปรมีดโกน VB มีดโกน VB Loops มีดโกน VB Logic

ASP Classic

แนะนำ ASP ไวยากรณ์ ASP ตัวแปร ASP ขั้นตอน ASP เงื่อนไข ASP ASP วนรอบ แบบฟอร์ม ASP คุกกี้ ASP เซสชัน ASP แอปพลิเคชัน ASP ASP #รวม ASP Global.asa ASP AJAX อีเมล ASP ตัวอย่าง ASP

การอ้างอิง ASP

ฟังก์ชัน ASP VB คีย์เวิร์ด ASP VB การตอบสนอง ASP คำขอ ASP แอปพลิเคชัน ASP เซสชัน ASP เซิร์ฟเวอร์ ASP ข้อผิดพลาด ASP ASP FileSystem ASP TextStream ไดรฟ์ ASP ไฟล์ ASP โฟลเดอร์ ASP พจนานุกรม ASP ASP AdRotator ASP BrowserCap การเชื่อมโยงเนื้อหา ASP ตัวหมุนเนื้อหา ASP ASP Quick Ref

กวดวิชา ADO

แนะนำ ADO ADO Connect ชุดระเบียน ADO จอแสดงผล ADO แบบสอบถาม ADO ADO Sort เพิ่ม ADO ADO Update ADO ลบ สาธิต ADO ADO เร่งความเร็ว

วัตถุ ADO

คำสั่ง ADO การเชื่อมต่อ ADO ข้อผิดพลาด ADO ADO Field พารามิเตอร์ ADO ADO พร็อพเพอร์ตี้ บันทึก ADO ชุดระเบียน ADO ADO สตรีม ประเภทข้อมูล ADO

วิธี การ เปิด ADO


❮ การอ้างอิงออบเจ็กต์ชุดระเบียนที่สมบูรณ์

วิธีการเปิดจะเปิดองค์ประกอบฐานข้อมูลที่ให้คุณเข้าถึงระเบียนในตาราง ผลลัพธ์ของคิวรี หรือชุดระเบียนที่บันทึกไว้

เคล็ดลับ:ปิดอ็อบเจ็กต์ Recordset ทุกครั้งหลังใช้งาน เพื่อทำให้ทรัพยากรระบบว่าง ตั้งค่าวัตถุ Recordset เป็น Nothing เพื่อลบออกจากหน่วยความจำโดยสมบูรณ์

ไวยากรณ์

objRecordset.Open source,actconn,cursortyp,locktyp,opt

Parameter Description
source Optional. Specifies a data source.  The source parameter may be one of the following:
  • A URL
  • A relative/full file path name
  • A Command object
  • An SQL statement
  • A stored procedure
  • A table name
actconn Optional. A connection string or a Connection object
cursortyp Optional. A CursorTypeEnum value that specifies the type of cursor to use when opening a Recordset object. Default is adOpenForwardOnly
locktyp Optional. A LockTypeEnum value that specifies the type of locking on a Recordset object. Default is adLockReadOnly
opt Optional. Specifies how to evaluate the source parameter if it is not a Command object. Can be one or more CommandTypeEnum or ExecuteOptionEnum values.

ตัวอย่าง

Open an ADO Table Recordset:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Customers", conn
%>

Open an ADO SQL Recordset:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>

CursorTypeEnum ค่า

Constant Value Description
adOpenUnspecified -1 Unspecified type of cursor
adOpenForwardOnly 0 Default. A forward-only cursor. This improves performance when you need to make only one pass through a Recordset
adOpenKeyset 1 A keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.
adOpenDynamic 2 A dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed
adOpenStatic 3 A static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.

LockTypeEnum ค่า

Constant Value Description
adLockUnspecified -1 Unspecified type of lock. Clones inherits lock type from the original Recordset.
adLockReadOnly 1 Default. Read-only records
adLockPessimistic 2 Pessimistic locking, record by record. The provider lock records immediately after editing
adLockOptimistic 3 Optimistic locking, record by record. The provider lock records only when calling update
adLockBatchOptimistic 4 Optimistic batch updates. Required for batch update mode

CommandTypeEnum ค่า

Constant Value Description
adCmdUnspecified -1 Unspecified type of command
adCmdText 1 Evaluates CommandText as a textual definition of a command or stored procedure call
adCmdTable 2 Evaluates CommandText as a table name whose columns are returned by an SQL query
adCmdStoredProc 4 Evaluates CommandText as a stored procedure name
adCmdUnknown 8 Default. Unknown type of command
adCmdFile 256 Evaluates CommandText as the file name of a persistently stored Recordset. Used with Recordset.Open or Requery only.
adCmdTableDirect 512 Evaluates CommandText as a table name whose columns are all returned. Used with Recordset.Open or Requery only. To use the Seek method, the Recordset must be opened with adCmdTableDirect. Cannot be combined with the ExecuteOptionEnum value adAsyncExecute.

ค่า ExecuteOptionEnum

Constant Value Description
adOptionUnspecified -1 Unspecified command
adAsyncExecute 16 The command should execute asynchronously. Cannot be combined with the CommandTypeEnum value adCmdTableDirect
adAsyncFetch 32 The remaining rows after the initial quantity specified in the CacheSize property should be retrieved asynchronously
adAsyncFetchNonBlocking 64 The main thread never blocks while retrieving. If the requested row has not been retrieved, the current row automatically moves to the end of the file. If you open a Recordset from a Stream containing a persistently stored Recordset, adAsyncFetchNonBlocking will not have an effect; the operation will be synchronous and blocking. adAsynchFetchNonBlocking has no effect when the adCmdTableDirect option is used to open the Recordset
adExecuteNoRecords 128 The command text is a command or stored procedure that does not return rows. If any rows are retrieved, they are discarded and not returned. adExecuteNoRecords can only be passed as an optional parameter to the Command or Connection Execute method
adExecuteStream 256 The results of a command execution should be returned as a stream. adExecuteStream can only be passed as an optional parameter to the Command Execute method
adExecuteRecord 512 The CommandText is a command or stored procedure that returns a single row which should be returned as a Record object

❮ การอ้างอิงออบเจ็กต์ชุดระเบียนที่สมบูรณ์