Tools used: vs.net beta2, orcale8
step:
1 Built an EMP table in the database, then add four fields in which EMPNO, ENAME, SAL, DEPTNO are added.
2 Open vs.Net Beta2 Create a C # Project -àWindows application. Control the following code:
Using system;
Using system.drawing;
Using system.collections;
Using system.componentmodel;
Using system.windows.forms;
Using system.data;
Using system.data.oledb;
Namespace EMPLOYEEEEEE
{
///
/// summary description for Form1.
/// summary>
Public class frMemp: system.windows.forms.form
{
Private system.windows.Forms.Label label1;
Private system.windows.Forms.Label label2;
Private system.windows.Forms.Label label3;
Private system.windows.Forms.Label label4;
Private system.windows.Forms.TextBox txtempno;
Private system.windows.Forms.TextBox TXtename;
Private system.windows.Forms.TextBox TXTESAL;
Private system.windows.Forms.TextBox txtDeptno;
Private system.windows.forms.button btnaddnew;
Private system.windows.Forms.Button Btnsave;
Private system.windows.Forms.Button Btndelete;
Private system.windows.Forms.Button Btnexit;
Private
System.Data.Oledb.oledbconnection
Conn
;
Private system.data.oledb.oledbcommand Command Command Comm;
Private system.data.oledb.oledbdataadapter dataadpt;
Private system.data.oledb.oledbcommandbuilder cbuild;
Private system.data.oledb.oledbdatareader dtread;
Private system.data.dataset dataset1;
Private system.data.datarow datarow1;
Private system.data.DataTable DataTable1;
PRIVATE STRING CONNSTR;
Private bool blnedit;
Private system.windows.Forms.Button btnedit;
///
/// Required Designer Variable.
/// summary>
Private system.componentmodel.Container Components = NULL;
Public FRMEMP ()
{
//
// Required for Windows Form Designer Support
//
InitializationComponent ();
CONNSTR = "provider = msdara; dsn = oracle; user ID = system; password = manager";
Conn
= New OLEDBCONNECTION (Conntr);
Cn.open ();
DataAdpt = New OledbDataAdapter ("SELECT * FROM EMP",
Conn
);
CBUILD = New OLEDBCommandbuilder (DataAdpt);
DataSet1 = New DataSet ("EMP");
DataTable1 = New DataTable ("EMP");
DataAdpt.Fill (DataSet1, "EMP");
//
// Todo: Add Any Constructionor Code After InitializationComponent Call
//
}
///
/// Clean Up Any Resources Being Used.
/// summary>
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing)
{
IF (Components! = NULL)
{
Components.dispose ();
}
}
Base.dispose (Disposing);
}
#Region Windows Form Designer Generated Code
///
/// Required Method for Designer Support - Do Not Modify
/// The contents of this method with the code editor.