Podstrony
- Strona startowa
- Callan Book 6 [Stage 11] (4)
- Callan Book 3 [Stage 5 & 6] (3)
- Callan Book 3 [Stage 5 & 6] (5)
- Callan Book 4 [Stage 7 & 8] (4)
- Callan Book 3 [Stage 5 & 6]
- Borland Delphi 7 Developer's Guide
- (27) Miernicki Sebastian Pan Samochodzik i ... Skarb generała Samsonowa tom 1
- Amanda Garret 4 Podwójny cel Cobb James
- Koontz Dean R Mroczne sciezki serca (SCAN dal
- Vincenzi Penny Niebywały skandal
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- motyleczeq.pev.pl
[ Pobierz całość w formacie PDF ]
.If on the otherhand you set the CommandType to ctStoredProc, the CommandText specifies the name ofthe stored procedure (and the component behaves like a TSQLStoredProcedure compo-nent).And finally, if you set CommandType to ctTable, CommandText contains the name ofthe individual tables (and the component behaves like a TSQLTable component).I just told you that the TSQLQuery, TSQLTable, and TSQLStoredProducedure are hardlynecessary in everyday use (the TSQLDataSet component is flexible enough).But thepurpose of these components might be to offer easier migration from existing BDEcode to dbExpress (where you can replace a regular BDE TTable component with anew dbExpress TSQLTable component, for example).In this case, using the general TSQLDataSet component, we can set the CommandTypeproperty to ctTable, and the CommandText property to CUSTOMER to select the customertable from the InterBase database.If you set the Active property to true, you get livedata at design time.Note, however, that there s no way to see the data just yet (wehave only used nonvisual components so far), so in the next section we ll add somedata-aware controls and discover how this new dbExpress dataset behaves.Data-Aware ControlsWe can now move to the Data Controls tab of the component palette, and startusing some of the data-aware controls to display the data we receive from the activeTSQLDataSet component.I should warn you beforehand that we cannot use thesecomponents immediately.In fact, this is the biggest difference between the BDE andthe dbExpress architecture.TSQLDataSet (and the related TSQLQuery, TSQLStoredProc,and TSQLTable components) returns a unidirectional cursor; meaning that you canmove forward, but not backward.This can be a problem if you try to connect aTSQLDataSet component to data-aware components.For example, if you drop aTDataSource and TDBGrid component next to the TSQLDataSet, connect the DataSetproperty of the TDataSource to the TSQLDataSet component, and try to connect theDataSource property of the TDBGrid to the TDataSource component, you will see exactlywhat I mean.At that time, you will get an error message (assuming the TSQLDataSetcomponent is still active otherwise you ll see the error message when you set theActive property of the TSQLDataSet component to true).The message indicates thatan Operation is not allowed on a unidirectional dataset see Figure 12.3 for theexact dialog.Apparently, the TDBGrid component performs just like an operation (caused byshowing more than one record at the same time, expecting the DataSet to bufferthese records for it to walk through them).Note that you can get exactly the sameerror message when using a TDBNavigator component and accidentally clicking theBack or First button.15 0672324806 CH12 12/12/02 2:41 PM Page 458458 CHAPTER 12 Data Access with dbExpressFIGURE 12.3 Unidirectional error message.In short: It s almost unworkable to connect data-aware controls directly to aTSQLDataSet component because of the unidirectional nature of this dataset.Why UnidirectionalSo, why do we get (or need) a unidirectional cursor in the first place? Well, theobvious advantage is speed.The Borland Database Engine (BDE) has never been ourbest friend (let s call it a friendly neighbor), but it has helped with the small andsimple database needs with the dBASE and Paradox local table formats, and theInterBase connectivity.Unfortunately, the BDE footprint and overhead hasn t beensmall, and BDE tables have never been known for amazing speed.That s an areawhere Borland wanted to show some real improvements.The new cross-platformdata access architecture called dbExpress is designed with this in mind.Hence, itprovides unidirectional cursors as results, with no overhead for buffering data ormanaging metadata.This, combined with the fact that Borland has announced thatdevelopment and support of the BDE has been frozen and SQL Links will even bedeprecated (in future versions of C++Builder), leads to the conclusion that dbExpresswill play an important role for data access with C++Builder.A unidirectional cursor is especially useful when you really only need to see theresults once or need to walk through your resultset from start to finish (again once).For example in a while-loop, processing the results of a query or stored procedure,and converting the contents of the records on-the-fly.Real-world situations wherethis is useful include reporting and Web server applications that produce dynamicWeb pages as output
[ Pobierz całość w formacie PDF ]