|
Article on other languages: |
액티브엑스 데이터 오브젝트(ADO)는 데이터 원본에 접근하기 위해 마이크로소프트 표준으로 제작된 컴포넌트 오브젝트 모델 객체들의 모임이자, 프로그래밍 인터페이스(API)이다.
들어가며프로그래밍 언어와 OLE DB 사이의 계층을 제공함으로써 개발자가 데이터 추가 방법을 알지 않더라도 데이터에 접근하는 프로그램을 짤 수 있게 도와 준다. 다만 연결을 위한 데이터베이스에 대해서는 알고 있어야 한다. ADO를 사용할 때에는 비록 사용자가 ADO를 사용하여 임의의 SQL 명령어를 실행할 수 있다 하더라도 데이터베이스에 접근하기 위해 SQL의 지식이 요구되지는 않는다. 종류ADO는 몇 가지 최상위 객체로 이루어져 있다:
기본 사용법ADO를 사용하여 데이터에 접근하고 이용하려면 다음과 같은 기본 과정을 밟아야 한다:
ASP의 예ADO를 사용한 예:
dim myconnection, myrecordset, name
set myconnection = server.createobject("ADODB.Connection")
set myrecordset = server.createobject("ADODB.Recordset")
myconnection.open mydatasource
myrecordset.open "Phonebook", myconnection
myrecordset.find "PhoneNumber = '555-5555'"
name = myrecordset.fields.item("Name")
myrecordset.close
set myrecordset = nothing
set myconnection = nothing
레코드셋 객체 기능을 사용하지 않고 SQL을 사용한 ASP 코드로는 다음과 같다.
dim myconnection, myrecordset, name
set myconnection = server.createobject("ADODB.connection")
myconnection.open mydatasource
set myrecordset = myconnection.execute("SELECT Name FROM Phonebook WHERE PhoneNumber = '555-5555'")
name = myrecordset(0)
VBA의 예
Dim myconnection as new ADODB.Connection
Dim myrecordset as new ADODB.Recordset
Set myconnection = CurrentProject.AccessConnection
myrecordset.Open "items", myconnection, adOpenKeyset, adLockOptimistic, adCmdTable
myrecordset.find "item_code = 'GI8293-23'"
if (not myrecordset.EOF) 'If the specified criteria cannot be satisfied, then the current record is EOF
myrecordset!item_name = "My New Item"
end if
myrecordset.update 'Actually commit the update to the data source
myrecordset.close
myconnection.close
소프트웨어 지원ADO는 VBA와 VBA for Office에서 지원을 받을 수 있다. 같이 보기바깥 고리
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.