[ Pobierz całość w formacie PDF ]
.TableScope indicateswhether the list should contain any or all of the following: ordinary tables, systemtables, synonyms, and views.Listing the fields in a tableThe GetFieldNames method fills an existing string list with the names of all fields(columns) in a specified table.GetFieldNames takes two parameters, the name of thetable for which you want to list the fields, and an existing string list to be filled withfield names:MyDBConnection.GetFieldNames('Employee', ListBox1.Items);Listing available stored proceduresTo get a listing of all of the stored procedures contained in the database, use theGetProcedureNames method.This method takes a single parameter: an already-existing string list to fill:MyDBConnection.GetProcedureNames(ListBox1.Items);Note GetProcedureNames is only available for TADOConnection and TSQLConnection.Connect i ng t o dat abas es 17-13 Ob t a i n i n g me t a d a t aListing available indexesTo get a listing of all indexes defined for a specific table, use the GetIndexNamesmethod.This method takes two parameters: the table whose indexes you want, andan already-existing string list to fill:SQLConnection1.GetIndexNames('Employee', ListBox1.Items);Note GetIndexNames is only available for TSQLConnection, although most table-typedatasets have an equivalent method.Listing stored procedure parametersTo get a list of all parameters defined for a specific stored procedure, use theGetProcedureParams method.GetProcedureParams fills a TList object with pointers toparameter description records, where each record describes a parameter of aspecified stored procedure, including its name, index, parameter type, field type, andso on.GetProcedureParams takes two parameters: the name of the stored procedure, and analready-existing TList object to fill:SQLConnection1.GetProcedureParams('GetInterestRate', List1);You can convert the parameter descriptions that are added to the list into the morefamiliar TParams object by calling the global LoadParamListItemsprocedure.BecauseGetProcedureParams dynamically allocates the individual records, your applicationmust free them when it is finished with the information.The global FreeProcParamsroutine can do this for you.Note GetProcedureParams is only available for TSQLConnection.17-14 Dev el oper  s Gui de Ch a p t e r18Chapter 18Understanding datasetsThe fundamental unit for accessing data is the dataset family of objects.Yourapplication uses datasets for all database access.A dataset object represents a set ofrecords from a database organized into a logical table.These records may be therecords from a single database table, or they may represent the results of executing aquery or stored procedure.All dataset objects that you use in your database applications descend from TDataSet,and they inherit data fields, properties, events, and methods from this class.Thischapter describes the functionality of TDataSet that is inherited by the dataset objectsyou use in your database applications.You need to understand this sharedfunctionality to use any dataset object.TDataSet is a virtualized dataset, meaning that many of its properties and methodsare virtual or abstract.A virtual method is a function or procedure declaration wherethe implementation of that method can be (and usually is) overridden in descendantobjects.An abstract method is a function or procedure declaration without an actualimplementation.The declaration is a prototype that describes the method (and itsparameters and return type, if any) that must be implemented in all descendantdataset objects, but that might be implemented differently by each of them.Because TDataSet contains abstract methods, you cannot use it directly in anapplication without generating a runtime error.Instead, you either create instancesof the built-in TDataSet descendants and use them in your application, or you deriveyour own dataset object from TDataSet or its descendants and write implementationsfor all its abstract methods.TDataSet defines much that is common to all dataset objects.For example, TDataSetdefines the basic structure of all datasets: an array of TField components thatcorrespond to actual columns in one or more database tables, lookup fields providedby your application, or calculated fields provided by your application.Forinformation about TField components, see Chapter 19,  Working with fieldcomponents.Under s t andi ng dat as et s 18-1 Us i n g TDa t a Se t d e s c e n d a n t sThis chapter describes how to use the common database funtionality introduced byTDataSet.Bear in mind, however, that although TDataSet introduces the methods forthis functionality, not all TDataSet dependants implement them.In particular,unidirectional datasets implement only a limited subset.Using TDataSet descendantsTDataSet has several immediate descendants, each of which corresponds to adifferent data access mechanism.You do not work directly with any of thesedescendants.Rather, each descendant introduces the properties and methods forusing a particular data access mechanism.These properties and methods are thenexposed by descendant classes that are adapted to different types of server data.Theimmediate descendants of TDataSet include" TBDEDataSet, which uses the Borland Database Engine (BDE) to communicatewith the database server.The TBDEDataSet descendants you use are TTable,TQuery, TStoredProc, and TNestedTable.The unique features of BDE-enableddatasets are described in Chapter 20,  Using the Borland Database Engine." TCustomADODataSet, which uses ActiveX Data Objects (ADO) to communicatewith an OLEDB data store [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • szamanka888.keep.pl