See All Titles |
![]() ![]() ADO (ActiveX Data Objects)ActiveX Data Objects (ADO) is an Automation-based interface technology for accessing data. ADO uses the OLE DB interface to access a broad range of data sources, including but not limited to data provided via ODBC. Although ODBC seems to be the standard in the market, ADO offers significant benefits. ADO is a rich and fully featured object model (see Chapter 7, "Objects Interfacing and Distribution," for details). The library name in which ADO lives is called ADODB. The ADO object model gives you fantastic flexibility. Users of RDO (Remote Data Objects) and DAO should have no problem moving to ADO because the overall design of ADO comes from Microsoft's experience in developing those interfaces. Microsoft's Remote Data Service (RDS) is a component of ADO that provides fast and efficient data connectivity and the data-publishing framework for applications hosted in Microsoft Internet Explorer. It is based on a client/server distributed technology that works over HTTP, HTTPS (HTTP over Secure Sockets layer), and DCOM application protocols. Using data-aware ActiveX controls, RDS provides data access programming in the style of Microsoft Visual Basic to Web developers who need to build distributed, data-intensive applications for use over corporate intranets and the Internet. The use of ADO ties your application to Win32, whereas using the Python DB API does not. After you have created the Connection object, you need to open a database connection by assigning a string value to the Open method. This string can be the name of a DSN (Data Source Name) or a complete connection string. >>> import win32com.client >>> adoConn = win32com.client.Dispatch('ADODB.Connection') >>> adoConn.Open('data source=mySQLServer;') >>> adoRS = adoConn.Execute ('truncate table tmp_table') >>> args = "34,25" >>> del adoRS >>> adoRS = adoConn.Execute ('insert into tmp_table values ('+args+')') >>> args = "11,12" >>> del adoRS >>> adoRS = adoConn.Execute ('insert into tmp_table values ('+args+')') >>> del adoRS >>> (adoRS, success) = adoConn.Execute ('Select c1, c2 from tmp_table') >>> while not adoRS.EOF: … vl_a = adoRS.Fields('c1').Value … vl_b = adoRS.Fields('c2').Value … print vl_a, vl_b … adoRS.MoveNext() … 34 25 11 12 >>> adoRS.MoveFirst() >>> (adoRS, success) = adoConn.Execute ('Select c1, c2 from tmp_table') >>> print vl_a, vl_b 34 25
|
Index terms contained in this sectionActiveX Data Objects (ADOs)connections databases opening DAO databases ActiveX Data Objects (ADOs) opening connections objects ActiveX Data (ADO) Remote Data (RDO) Remote Data (RDS) opening connections databases RDOÓ Ò RDSÓ Ò Remote Data Objects (RDOs) Remote Data Service (RDS) |
© 2002, O'Reilly & Associates, Inc. |