Hi All My Question related to VB 2008 Pro running ODP.net (11.1) and connected to Oracle Database Called RECAT which having a Table Called Clients with the following structure :
C#
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 intoCLIENTS
(CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN)
Values
(1305, 'HAITHAM JAMAL ABU JAMOOS', 'SHARJAH', 'Y');
Insert intoCLIENTS
(CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN)
Values
(1306, 'JAIN LEE NOMM', 'ABU DHABI', 'Y');
Insert intoCLIENTS
(CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN)
Values
(1307, 'GEORGE KARAM HANNA', 'DUBAI', 'Y');
Insert intoCLIENTS
(CLNT_ID, CLNT_NAME, CLNT_EMRT, COMP_YN)
Values
(1308, 'KRISTOPHER ABI NADER', 'ABU DHABI', 'Y');
I Did a simple VB .net form to access the Datasource, taking the contents of the table to a dataset called "clnt_ds" and do the basic Insert/Update and Delete operations to a dataset and then return the dataset back to database by the methos DataAdapter.update
But after I'm did so I discovered that still the oracle database didn't got the update and now rows inserted nor rows updated or deleted
I need to accomplish the task by using ADO.Net Classes (DataTable,DataRow)
Can you Help Me please and here you are the code
Code:
VB.NET
Imports Oracle.DataAccess.Client
PublicClass FRMCLNT
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CONNSTR AsString
CONNSTR = "data source=RECAT;User ID=PAYOPER;Password=PAYOPER"Dim oracn AsNew OracleConnection(CONNSTR)
Try
oracn.Open()
If oracn.State = ConnectionState.Open ThenDim orada AsNew OracleDataAdapter("select * from clients", oracn)
Dim clnt_ds AsNew 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 AsNew 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()
EndIfCatch oraex As OracleException
MsgBox(oraex.Number + " - " + oraex.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
oracn.Close()
oracn.Dispose()
EndTryEndSubEndClass
Please help me to get this working noting that the code doesn't give me any error and it's showing all messageboxes as programmed but it's not updating the database.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
tomason7 reputationPosted Jan 26, 2011, 4:53 PM EST
0
Your issue looks interesting. I want to help you with a method of data export. If you want to export data from database, you may choose it, it's very fast and stable when you export data from database. And now, it's free for everyone. You may visit here for further information: http://www.e-iceblue.com/Introduce/free-dataexport-component.html
tomason7 reputationPosted Jan 26, 2011, 4:53 PM EST
http://www.e-iceblue.com/Introduce/free-dataexport-component.html