180 likes | 272 Views
Let’s do data!. Venelina Jordanova JEI Varna, Bulgaria. Who am I ?. Master degree in CS from TU of Varna MCP FoxPro developer since v 2.0 Developer of wide range information systems
E N D
Let’s do data! Venelina Jordanova JEI Varna, Bulgaria The Power of CursorAdapters
Who am I ? • Master degree in CS from TU of Varna • MCP • FoxPro developer since v 2.0 • Developer of wide range information systems • Speaker at Frankfurt DevCon 2003, 2004, 2005 and 2006, Prague 2004, 2005, 2006 and 2007, Utrecht 2006, Paris 2006 and Microsoft DevDays - Bulgaria • Owner of JEI - Varna, Bulgaria Outsourcing center Venelina@OutsourcingITservices.net The Power of CursorAdapters
Overview • CursorAdapter class specifics • Special events of CursorAdapter class • Data retrieval tricks • Different data engines specifics • Conflict management • Error processing and server side debugging The Power of CursorAdapters
Benefits of CursorAdapter class • Working in mixed environment • Access to various data sources • Creates VFP cursor • Automatically generated SQL statements • Large set of very useful events • Error handling The Power of CursorAdapters
BeforeCursorFill event • Closes existing cursor • lUseCursorSchema, lNoDataOnLoad, cSelectCmd parameters passed by reference • Changed cSelectCmd will be used • Make sure you pass them to next subclassing level by reference, too The Power of CursorAdapters
BeforeCursorRefresh event • Does not close existing cursor • cSelectCmd statement used by last CursorRefresh is reused • Make sure to pass all the editable parameters by reference The Power of CursorAdapters
Events raised before sending updates • Events: • BeforeCursorUpdate • BeforeInsert • BeforeUpdate • BeforeDelete • Make sure to pass all the editable parameters by reference • Developer specified commands The Power of CursorAdapters
Events raised after sending updates • Events: • AfterCursorUpdate • AfterInsert • AfterUpdate • AfterDelete • Error handling • Obtain auto-generated values in AfterInsert event The Power of CursorAdapters
Parameterized SELECT commands • Prefix parameter variables with “?” when working with ODBC provider • make sure all the parameters exist and have correct value at the time when object initializes and every time when CursorFill or CursorRefresh is executed • ADOCommand parameters when using ADODB provider The Power of CursorAdapters
Tables with more than 255 fields • Split into “main” and “slave” cursor • Updating a record • Inserting a new record • Deleting a record • Use transactions to ensure data consistency The Power of CursorAdapters
Querying more than one table in SELECT command • Tables property • UpdateFieldList property • CursorAdapter class generates a complex update statement • DELETE commands are generated for all the tables that CursorAdapter object updates. The Power of CursorAdapters
Using stored procedures • InsertCmd = “EXECUTE InsertOrderEntry … “ • Passing parameters The Power of CursorAdapters
ODBC or ADO? • Establishing a conection • ODBC • SQLSTRINGCONNECT() or SQLCONNECT() • ADODB loConnDataSource = CREATEOBJECT('ADODB.Connection') loConnDataSource.ConnectionString = [Provider=SQLOLEDB.1...] loConnDataSource.Open() This.DataSource = CREATEOBJECT('ADODB.RecordSet') This.DataSource.ActiveConnection = loConnDataSource The Power of CursorAdapters
Working with different database engines • Using quoted identifiers • Delimiter characters for different database servers • Syntax specifics • ANSI-92 compliant functions • Using server-specific functions The Power of CursorAdapters
Retrieving auto generated field values • @@IDENTITY variable • The functions SCOPE_IDENTITY() and IDENT_CURRENT( 'table_name' ) • CursorAdapter class auto-refresh functionality • InsertCmdRefreshCmd • InsertCmdRefreshFieldList • InsertCmdRefreshKeyFieldList The Power of CursorAdapters
Error processing • BreakOnError property of CursorAdapter class • Errors, raised by backend database • Passing parameters • Parameters data types • Manage conflicts The Power of CursorAdapters
Debugging • T-SQL commandexecution • Using SELECT statement to debug update conflicts • SQL Server Profiler The Power of CursorAdapters
Thank you! Please remember to fill out your evaluation. The Power of CursorAdapters