In C #, the Datawindow. Net component processes data. Datawindow. Net is a data access component developed by PB for MS. Net.
1. Install
First install. net2003, Framework Version 1.1, then install the DataWindow. Net component and design the compilation environment.
After installation, The Sybase DataWindow control tab is displayed during the design of the. net2003 form.
2. Use DataWindow
Controls can be directly used in the C # form.
3. Design DataWindow
Design Data windows in the PB or DataWindow design environment and store them in. pbl for program calls.
After the release, it can be compiled into the. pbd file format.
4. Call DataWindow in c #
A) create a Datawindow control on the form and name it dw.
B) create a Transaction control on the form and name it Trans.
C) initialize the Transaction control.
Trans. dbms = Sybase. dataWindow. dbmsType. oleDb; // database connection method Trans. password = "123"; Trans. userID = "sa"; Trans. autoCommit = false; Trans. lock = "RC"; Trans. dbParameter = "PROVIDER = 'sqloledb', DATASOURCE = 'xiance', PROVIDERSTRING = 'database = Demo'"; // database connection string Trans. connect (); // Connect to the database
D) display data window
Dw. libraryList = "test. pbl "; // used after release. pbd file dw. dataWindowObject = "datawindowName"; // data window name dw. setTransaction (Trans); dw. retrieve (); // Display data window
E) close the connection.
Trans. Disconnect ();
5. c # Use the DataWindow control to operate data
A) add
Int row = this. dw. insertRow (0); // Insert a record dw. setRow (row); dw. setItemString (row, "ID", "100"); // assign the dw value to the field. setItemString (row, "name", "name"); // assign a value to the field
B) Delete
This. dw. DeleteRow (1); // delete the first row of record
C) save
This. dw. UpdateData (true, true); Trans. Commit (); // data is written to the database after being submitted.
6. Description
The above is just a brief description of the usage of DataWindow in c #. In actual development, there will be many details, especially when designing the data window.