630 likes | 829 Views
PWB508: DataWindow . NET, Usage, Features and Roadmap. David Avera Staff Engineer davera@sybase.com August 15-19, 2004. The Enterprise. Unwired. The Enterprise. Unwired. Industry and Cross Platform Solutions. Manage Information. Unwire Information. Unwire People.
E N D
PWB508: DataWindow .NET, Usage, Features and Roadmap David Avera Staff Engineer davera@sybase.com August 15-19, 2004
The Enterprise. Unwired. Industry and Cross Platform Solutions Manage Information Unwire Information Unwire People • Adaptive Server Enterprise • Adaptive Server Anywhere • Sybase IQ • Dynamic Archive • Dynamic ODS • Replication Server • OpenSwitch • Mirror Activator • PowerDesigner • Connectivity Options • EAServer • Industry Warehouse Studio • Unwired Accelerator • Unwired Orchestrator • Unwired Toolkit • Enterprise Portal • Real Time Data Services • SQL Anywhere Studio • M-Business Anywhere • Pylon Family (Mobile Email) • Mobile Sales • XcelleNet Frontline Solutions • PocketBuilder • PowerBuilder Family • AvantGo Sybase Workspace
Terminology • The Microsoft .NET Framework • The class library • Comprehensive library, everything from soup to nuts. • The Common Language Runtime • MSIL – Microsoft Intermediate Language • Just in time compiling • The runtime execution engine (it is NOT a VM) • Managed execution.
Terminology • Interoperation • The ability of .NET managed programs to communicate and Interoperate with non-managed programs. • Allows the use of legacy programs without massive conversions.
As of last year’s TechWave • The DataWindow .NET prototype was demonstrated at TechWave 2003 • Most of the DataWindow methods worked. • Most of the functionality was in place. • We had proven that our model would work and that DataWindows could be implemented under the .NET Framework
During the last year • Continuous refactoring and refinement. • We adopted naming conventions more in line with .NET standards. • We overlayed an object model over the DataWindow engine (aka DataWindow server). • This model will continue to be enhanced.
Installed Components • Managed Assemblies • DataWindow.DLL • The front end for DataWindow .NET • This is what your program interacts with • DataWindowInterop.DLL • Manages communication with the DataWindow server • Performs data marshalling as necessary • PBData100.DLL • Interface to ADO .NET
Installed components • Unmanaged components • PBDWN100.DLL • PBSHR100.DLL • The same one as PowerBuilder uses. • Database drivers • The same ones that PowerBuilder uses
Create an application using DataWindow .NET • Create a new C# project
Drop a DataWindowControl on the form • Select DataWindowControl from the Sybase tab in the toolbox
The DataWindow Reference • When you drop a DataWindowControl, DataStore or a Transaction onto a Form a reference is created to DataWindow
Reference Properties • Take note of the path and the CopyLocal properties
Size the DataWindowControl • Displayed as below
Add a transaction object • Again, using the toolbox.
The transaction object added • The transaction object is displayed off of the form.
Define the transaction properties • RMB on the transaction and select properties
Test our transaction object • RMB on the SQLCA object and select “Test Connection”
Set some DataWindowControl properties • LibraryList
Set some DataWindowControl properties • DataWindow object
Access the Design Tool • DataWindow Designer
Use the Design Tool • It’s the same as the PowerBuilder DataWindow Painter
Add code to connect and retrieve • Use the form’s Load event
Exploring DataWindow .NET • Using the Visual Studio Object Browser
DataWindow .NET Interfaces • IDataWindowBase • Many (in fact most) of the methods you are familiar with in the PowerBuilder DataWindow
DataWindow .NET Interfaces • IDataStore • Inherits IDataWindowBase and adds remoting.
DataWindow .NET Interfaces • IDataWindow • Adds UI related methods and properties
Principle DataWindow .NET Classes • DataWindowControl • The visual container for a DataWindow object • Inherits from System.Windows.Form.Control • Implements the IDataWindow interface • DataStore • The non visual container for a DataWindow object • Inherits from System.ComponentModel.Component • Implements the IDataStore interface
Principle DataWindow .NET Classes • Transaction • Inherits System.ComponentModel.Component • DataWindowChild • Represents a child DataWindow, either a Drop Down DataWindow or nested child DataWindow. • Implements IDataWindowBase. • GraphicObject and descendents • Represents an object on a DataWindowControl or within a DataStore.
Database Operations in DataWindow .NET • Two transaction classes are used • Sybase.DataWindow.Transaction • Enables the use of the PowerBuilder DBI to connect to a database and manage the transaction. • Sybase.DataWindow.AdoTransaction • Enables the sharing of an ADO .NET database connection • Only OleDbConnection is supported in the first release. .
Database Operations in DataWindow .NET • Methods for Setting Database Connection into DataWindow • IDataWindowBase.SetTransaction(Sybase.DataWindow.Transaction) • IDataWindowBase.SetTransaction(Sybase.Datawindow.AdoTransaction)
Database Operations in DataWindow .NET • Using the Transaction object • SQLCA.Connect( ); • ds_1.SetTransaction(SQLCA); • ds_1.Retrieve(); • // change data • ds_1.SetItemString(2, 1, “Sybase”); • // update database • ds_1.UpdateData(); • // commit data • SQLCA.Commit();
Database Operations in DataWindow .NET • Using AdoTransaction • System.Data.OleDb.OleDbConnection oleDbConn = new System.Data.OleDb.OleDbConnection(); • oleDbConn.ConnectionString = @"User ID=dba; Password=sql;Data Source=EAS Demo DB V4; Provider=\"ASAProv.90\""; • oleDbConn.Open(); • AdoTransaction myAdoTrans = new AdoTransaction(oleDbConn, null); • // After calling BindConnection, you will find IsBound become true. • myAdoTrans.BindConnection();
Database Operations in DataWindow .NET • Using AdoTransaction • DataStore ds_1 = new DataStore(); • // Start an ADO.NET Transaction • System.Data.OleDb.OleDbTransaction myOleDbTrans; • myOleDbTrans = oleDbConn.BeginTransaction(); • // Create a DataWindow transaction • Sybase.DataWindow.Transaction myAdoTrans = new Sybase.DataWindow.Transaction( );
Database Operations in DataWindow .NET • Using AdoTransaction • // For any DataWindow db operation, you must bind the ADO.NET connection to the DataWindow .NET transaction • myAdoTrans.Transaction = myOleDbTrans; • ds_1.SetTransaction(myAdoTrans); • ds_1.Retrieve(); • ds_1.SetItemString(1, “dept_name”, “ADC”); • ds_1.UpdateData(); • myOleDbTrans.Commit(); // Commit the changes • // OR myOleDbTrans.Rollback(); // Rollback the changes.
DataWindow .NET Events • Events are implemented using the .NET delegate model. • Some event names differ from the PowerBuilder names so as to conform to .NET naming styles.
DataWindow .NET Events • The interfaces determine which events apply to which objects.
DataWindow .NET Events • Event arguments are classes • Many argument properties use enumerations
DataWindow .NET Events • About Mouse events • The PowerBuilder mouse events supply parameters specific to the DataWindowControl • DataWindow .NET mouse events supply the same arguments as regular .NET mouse events. • Use the DataWindowControl’s “ObjectUnderMouse” property for one stop shopping.
DataWindow .NET Events • ObjectUnderMouse
DataWindow .NET Events • Sample code using ObjectUnderMouse private void MyMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { ObjectAtPointer OAP = dataWindowControl1.ObjectUnderMouse; Sybase.DataWindow.GraphicObject GOB = OAP.Gob; if ( GOB is GraphicObjectEditableColumn ) { GraphicObjectEditableColumn EditGob = (GraphicObjectEditableColumn) GOB; MessageBox.Show ( "ColumnName = " + EditGob.Name ); } }