CREATE TABLE PAYOPER.CLIENTS ( CLNT_ID NUMBER(4) NOT NULL , <== Primary Key CLNT_NAME VARCHAR2(35 BYTE) NOT NULL, CLNT_EMRT VARCHAR2(15 BYTE), COMP_YN VARCHAR2(1 CHAR) ) The following data exist in the table:- Insert into CLIENTS (CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN) Values (1305, 'HAITHAM JAMAL ABU JAMOOS', 'SHARJAH', 'Y'); Insert into CLIENTS (CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN) Values (1306, 'JAIN LEE NOMM', 'ABU DHABI', 'Y'); Insert into CLIENTS (CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN) Values (1307, 'GEORGE KARAM HANNA', 'DUBAI', 'Y'); Insert into CLIENTS (CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN) Values (1308, 'KRISTOPHER ABI NADER', 'ABU DHABI', 'Y');
Imports Oracle.DataAccess.Client Public Class FRMCLNT Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim CONNSTR As String CONNSTR = "data source=RECAT;User ID=PAYOPER;Password=PAYOPER" Dim oracn As New OracleConnection(CONNSTR) Try oracn.Open() If oracn.State = ConnectionState.Open Then Dim orada As New OracleDataAdapter("select * from clients", oracn) Dim clnt_ds As New DataSet("clients") orada.MissingSchemaAction = MissingSchemaAction.AddWithKey orada.Fill(clnt_ds, "CLIENTS") oracn.BeginTransaction() '******************** ' ADDING RECORDS '******************** Dim tblclients As DataTable tblclients = clnt_ds.Tables("CLIENTS") Dim datarw As DataRow datarw = tblclients.NewRow datarw("CLNT_ID") = 8999 datarw("CLNT_NAME") = "Jamsheed Ishaaq " datarw("CLNT_EMRT") = "RAK" datarw("COMP_YN") = "Y" tblclients.Rows.Add(datarw) MessageBox.Show("Row Added Successfully") Dim oracmdbld As New OracleCommandBuilder(orada) orada.Update(clnt_ds, "CLIENTS") '******************** ' Edit RECORDS '******************** datarw = tblclients.Rows.Find(1305) datarw.BeginEdit() datarw("CLNT_EMRT") = "DUBAI" & datarw("COMP_YN") = "Y" datarw.EndEdit() MessageBox.Show("Row Modified Successfully" + datarw("CLNT_EMRT")) orada.Update(clnt_ds, "CLIENTS") '******************** ' Delete RECORDS '******************** datarw = tblclients.Rows.Find(1307) datarw.Delete() MessageBox.Show(" 1 Row deleted Successfully") orada.Update(clnt_ds, "CLIENTS") '******************** ' Save Changes '******************** MessageBox.Show(" DML Operations Finished" & Chr(13)) oracmdbld.Dispose() orada.Dispose() End If Catch oraex As OracleException MsgBox(oraex.Number + " - " + oraex.Message) Catch ex As Exception MessageBox.Show(ex.Message) Finally oracn.Close() oracn.Dispose() End Try End Sub End Class