Tune the DataWindow Operation Database in .NET

zhaozj2021-02-16  45

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 {///

/// DataWindowTest's summary description. /// public class DataWindowTest: System.Windows.Forms.Form {private Sybase.DataWindow.DataWindowControl dw; private Sybase.DataWindow.Transaction Trans; private System.Windows.Forms.Button btnRetrieve; private System.Windows. Forms.Button Btndelete; private system.windows.Forms.Button BtnInsert; private system.windows.forms.button btnsave; private system.componentmodel.icontainer component;

Public DataWindowTest () {// // Windows Form Designer Support for // InitializationComponent ();

// // Todo: Add any constructor code after INITIALIZEComponent call //}

///

/// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = Null) {components.dispose ();}} Base.Dispose (4);

#REGION Windows Form Designer The code ///

/// designer supports the required method - do not use the code editor to modify the // / this method.

/// 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

转载请注明原文地址:https://www.9cbs.com/read-26904.html

New Post(0)