Sunday, August 12, 2012

Using ADO Connection, LockType, CursorLocation




Option Explicit

Public AdoCn As ADODB.Connection
Public AdoRs As ADODB.Recordset
Public strConnectionString As String

-------------------------------------------------- ---------------------------
<1. When the type of access and connectivity>
strConnectionString = "Provider = Microsoft.jet.oledb.4.0; Data Source =" & App.Path & "DataBase.mdb"
App.Path is currently running above the relative path of the program.


-------------------------------------------------- ---------------------------
<2. When the format of the SQL server and connect>
strConnectionString = "Provider = SQLOLEDB; Data source = Server_Name; Initial catalog = Db_name; User ID = account; Password = off-duty"


-------------------------------------------------- ---------------------------
<Connection object when you open the Format>
Set AdoCn = New ADODB.Connection

AdoCn.Open strConnectionString


-------------------------------------------------- ---------------------------
<Record set yiyonghalttae the type of object>
Set AdoRs = New ADODB.Recordset

AdoRs.ActiveCommand = AdoCn

AdoRs.CursorLocation = adUseClient cursor positioning or Clint Server

AdoRs.CursorType = adOpenStatic cursor feature set
A. static: the original record itself (value) as to bring
Two. Keyset: Get the location of the records, rather than the value (pointer value imported)
Daeyiteo work check the contents of the others can be added, no one.
Three. Dynamic: Verify the contents of the location, gets the value added. (Keyset of the Generative.)
Only rarely used because the risk of overload down under.
Four. FowardOnly: Divi must read once. Function of the minimum.

AdoRs.LockType = adLockOptimistic to avoid duplication of work.
A. Optimistic: When the physical storage is not working when you lock geoleojum (positive lock)
Two. Pessimistic: As soon as the pre-rock walk in memory giving olrija (passively Rock)
Three. Readonly: read-only lock. (Only when reading ten thousand.)
Four. Batch Optimistic: client-only. Connectionless locks.
ex) when working with large amounts of disconnects after working on the client side
When the task is completed by connecting the server-side use to send ...

AdoRs.Open Query Sql statement, the record open


-------------------------------------------------- ---------------------------
<Record set object close format>
AdoRs.Close

Set AdoRs = Nothing


-------------------------------------------------- ---------------------------
<Connection Object Close format>
AdoCn.Close

Set AdoCn = Nothing

No comments:

Post a Comment