Podobne
- Strona startowa
- Van Roy Peter, Haridi Seif Concepts, Techniques, and Models of Computer Programming
- [eBook] DirectX 3D Graphics Programming Bible
- (ebook PDF) Schreiner Object oriented Programming With A
- Advanced 3D Game Programming with DirectX 9
- Program Swiatowej Polityki Zydo
- Programming Windows Games in Borland C
- Programowanie w Delphi i C Builder
- White Stephen Program (2)
- SAMS Teach Yourself PHP4 in 24 Hours
- Sams' Teach Yourself Linux In 24 Hours
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- ewelina111.htw.pl
Cytat
Do celu tam się wysiada. Lec Stanisław Jerzy (pierw. de Tusch-Letz, 1909-1966)
A bogowie grają w kości i nie pytają wcale czy chcesz przyłączyć się do gry (. . . ) Bogowie kpią sobie z twojego poukładanego życia (. . . ) nie przejmują się zbytnio ani naszymi planami na przyszłość ani oczekiwaniami. Gdzieś we wszechświecie rzucają kości i przypadkiem wypada twoja kolej. I odtąd zwyciężyć lub przegrać - to tylko kwestia szczęścia. Borys Pasternak
Idąc po kurzych jajach nie podskakuj. Przysłowie szkockie
I Herkules nie poradzi przeciwko wielu.
Dialog półinteligentów równa się monologowi ćwierćinteligenta. Stanisław Jerzy Lec (pierw. de Tusch - Letz, 1909-1966)
[ Pobierz całość w formacie PDF ]
.ODBC programming and OLE programming are similar in that the application, in both environments,does the following:Calls API functions to load the appropriate DLL(s)Uses functions in the DLL(s) to connect to a data sourceCreates and executes queriesProcesses resultsCleans upFor ODBC, to load the appropriate DLL(s), the application links with Odbc32.lib, which is the importlibrary for the ODBC Driver Manager.The Driver Manager DLL, Odbc32.dll, loads when theapplication loads.The application calls ODBC API functions in the Driver Manager DLL, and theDriver Manager in turn calls functions in the appropriate ODBC driver.For OLE DB, the application initializes the COM libraries.The application loads the proper dataprovider according to the CLSID parameter that it passes to the CoCreateInstance function.After that, the application can obtain pointers to the interfaces that the provider exposes and can callfunctions directly in the provider.For ODBC, the application connects to the data source by calling SQLAllocEnv,SQLAllocConnect, and SQLDriverConnect (or by calling SQLAllocHandle) to allocate aconnection handle.The application then builds a connection string containing the user ID, password,and the name of the data source.For OLE DB, the application connects to the data source by building an array of property structuresthat contain the user ID, password, and the name of the data source.The application then callsIDBProperties::SetProperties to set initialization properties.(Listing 16.2 doesn't showthis step, but tomorrow you will see the code for this.) Then the application callsIDBInitialize::Initialize to initialize the data source object.The fundamental differences between the model for OLE DB and the model for ODBC areOLE DB uses COM interfaces, whereas ODBC uses traditional DLLs and static linking with animport library.OLE DB uses structures that contain the user ID, password, and DSN, whereas ODBC useskeywords in a string variable.In OLE DB, setting the user ID, password, and DSN is separate from actually connecting to thedata source, which enables the connection properties to be persisted by the application moreeasily than in ODBC.In OLE DB, the application uses COM interfaces to set properties in a query object and thencalls a member function to execute the query (you will see code for this later this week),whereas ODBC uses the SQLAllocStmt and SQLExecDirect functions to send SQLstrings to the database.In OLE DB, the application receives results from queries in Rowset objects, whereas ODBCuses the SQLGetData and SQLGetData functions to retrieve the data from queries.As you can see, OLE DB takes an object-oriented, or COM, approach, whereas ODBC takes atraditional API-based approach to database client programming.The OLE DB Object HierarchyThe OLE DB interface is composed of several major objects: Enumerator, DataSource,Session, Command, Rowset, Index, Error, and Transaction.In Figure 16.5, you can seethe hierarchy of the OLE DB objects.During this week you will have a chance to look at each objectin detail.A brief survey of the major OLE DB objects follows.Figure 16.5 : The OLE DB object hierarchy.EnumeratorThe Enumerator object retrieves information regarding the OLE DB providers and enumeratorsavailable on this system.Much of the information about OLE DB providers is stored in the registry.An Enumerator exposes the ISourcesRowset interface and returns a Rowset describing alldata sources and enumerators visible to the Enumerator.Using the Enumerator object is better than directly accessing the registry, because in the future thisinformation might be stored somewhere else.The Enumerator object abstracts the source of thedata provider information from an application, enabling it to work even if a new enumeration methodis created.DataSourceA data consumer uses a DataSource object to connect to a data provider.A data provider can be anOLE DB application, a database, or an ODBC data source using the OLE DB ODBC data sourceprovider.When connecting to a database, a DataSource object encapsulates the environment andconnection information, including a username and password.A DataSource object can be madepersistent by saving its state to a file.SessionA Session object provides a context for transactions.Sessions create an environment toencapsulate transactions, generate rows of data from a data source, and generate commands that canquery and manipulate the data source.A DataSource object creates a Session object; aDataSource object can create multiple Session objects.CommandA Command object processes commands.An OLE DB data provider isn't required to processcommands.A Command object can create commands that can query or manipulate a data source.Theresult of a query creates a Rowset object.A Command object can also create multiple row sets.When accessing a data source, Command objects can create prepared statements and queries thatreturn multiple row sets.RowsetA Rowset object accesses information from a data source in a tabular form.A Rowset object can becreated as the result of executing a command.If the data provider doesn't support commands (which itis not required to provide), a row set can be generated directly from the data provider.The capabilityto create row sets directly is a requirement of all data providers.A Rowset object also is used whenaccessing data source schema information
[ Pobierz całość w formacie PDF ]