Tune the DataWindow Operation Database in .NET
Sybase has launched a PB 10 beta1 version in 2004/1/19, which contains DataWindow.Net 1.0, which is a distant excitement! Today, in the PB market, today, Sybase has finally launched today. DataWindow.net, which supports the most original events and properties of DataWindow, and PB technology can finally reassure!!
Come down the installer, so that you have a simple example in VS.NET2003, find that it is really easy to use! Source code, the interface is as follows:
Using system; using system.collections; using system.componentmodel; using system.windows.form;
Namespace cjgl.Report {///
Public DataWindowTest () {// // Windows Form Designer Support for // InitializationComponent ();
// // Todo: Add any constructor code after INITIALIZEComponent call //}
///
#REGION Windows Form Designer The code ///
/// summary> private void InitializeComponent () {this.components = new System.ComponentModel.Container (); this.btnRetrieve = new System.Windows.Forms.Button (); this.btnDelete = new System.Windows. Forms.button (); this.btninsert = new system.windows.forms.button (); this.dw = new sybase.dataWindow.DataWindowControl (); this.trans = new sybase.dataWindow.Transaction (this.Components); This.btnsave = new system.windows.Forms.Button (); this.suspendlayout (); // // btnretrieve // this.btnretrieve.Anchor = ((System.Windows.Forms.Anchorstyles) ((System.Windows.) Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnRetrieve.Location = new System.Drawing.Point (360, 297); this.btnRetrieve.Name = "btnRetrieve"; this.btnRetrieve .TabIndex = 1; this.btnRetrieve.Text = "Retrieve"; this.btnRetrieve.Click = new System.EventHandler (this.btnRetrieve_Click); // // btnDelete // this.btnDelete.Anchor = ((System.Windows .Forms.anchorstyles ((System.Windows.Forms.Anchorstyles.Bottom | System.Windows.Forms.Anchorstyles.right)); this.btndelete.location = new system.drawing.point (260, 296); this.btndelete.name = "btndelete"; this.btndelete.tabindex = 2; this.btndelete.text = "delete"; this.btndelete.click = new system.eventhandler (this.btndelete_click); // // btnInsert // this.btninsert. Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnInsert.Location = new System.Drawing.Point ( 152, 295); this.btninsert.name = "btninsert";
this.btninsert.tabindex = 3; this.btninsert.text = "insert"; this.btninsert.click = new system.eventhandler (this.btninsert_click); // // dw // this.dw.anchor = ((((( System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms. Anchorstyles.right))))))); this.dw.dataWindowObject = "dw_customer"; this.dw.libraryList = "D: // program files // Sybase10 // DataWindow Builder 1.0 // DWB100.PBL"; this.dw.location = New System.drawing.Point (5, 5); this.dw.name = "dw"; this.dw.scrollbars = system.windows.forms.scrollbars.both; this.dw.size = new system.drawing. Size (432, 280); this.dw.Tabindex = 4; this.dw.text = "DataWindowControl1"; this.dw.typeofdataWindow = sybase.dataWindow.DataWindowType.Grid; // // Trans // this.trans. Database = "asademo9.dba"; this.Trans.dbms = sybase.dataWindow.dbmstype.Oledb; this.trans.dbparameter = "provide R = / 'asaprov.90 /'; this.trans.password = "sql"; this.trans.servername = "asademo9"; this.trans.userid = "dba"; // btnsave // this. btnSave.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnSave.Location = new System.Drawing. Point (46, 296); this.btnsave.Name = "btnsave"; this.btnsave.tabindex = 5; this.btnsave.text = "& save"; this.btnsave.click = new system.eventhandler (this.btnsave_click );
//////////////////////////////////Ww.drawing.size (6, 14); this.clientsize = new system.drawing.size (444, 333); this.Controls.add (this.btnsave); This.Controls.add (this.dw); this.controls.add (this.btninsert); this.controls.add (this.btndelete); this.btnretrieve; this.name = "DataWindowTest); THIS.NAME =" DataWindowTest "; This.Text =" Use DataWindow.net design "; this.ResumeLayout (false);} #ENDREGION
Private void btnretrieve_click (object sender, system.eventargs e) {Try {if (! trans. on.isconnected {trans.connect (); dw.settransobject (trans); dw.retrieve ();
} Catch (sybase.datawindow.dberrorException ee) {messagebox.show ("Database connection error!" Ee.sqlerrortext); return;}}
Private void btninsert_click (object sender, system.eventargs e) {// Insert a line INT INSERTROW = dw.insertrow (0); dw.scroll (inSertrow); // assign initial value dw.setitemdouble (Insertrow, "ID", 9999 ); Dw.setitemstring (INSERTROW, "FNAME", "Huang"); dw.setItemString (InsertRow, "Lname", "Yong"); dw.SetItemString (Insertrow, "Address", "Changsha"); dw.setItemString (Insertrow, "City", "changsha");
Private void btndelete_click (object sender, system.eventargs e) {dw.deleterow (dw.currentrow);}
Private void btnsave_click (object sender, system.eventargs e) {Try {dw.update (); trans.commit ();} catch (sybase.dataWindow.dberrorexce) {messagebox.show ("Update is not successful! Reason:" Ee.sqlerrorText); trans. rollback ();} catch (sybase.datawindow.datawindown) {MessageBox.show ("Data window has not created!"); trans. rollback ();} catch (Sybase.DataWindow. MethodfailureExcetion EE) {MessageBox.show ("Update Upset! Cause:" EE.MESSAGE.TOSTRING ()); trans. Rollback ();}}}} After creating a PBL library and DataWindow objects via PB, or DataWindow Builder, Just like in the PB, specify the PBL library location and the DataWindow control related to the DataWindow object, you can perform related operations such as dw.settransobject (trans); dw.retrieve (); how? It's very familiar with the original PB programmers!
If you feel good, you can go to the Taoqing website to download the PB10bete1 version :) http://www.pdriver.com/display.asp?key_id=1563