Using VB.NET with ODP.NET OracleConnection. Need to update data in Oracle DB.
I thought I could just create an OracleCommand with a SQL update statement as the CommandText. Here is the SQL command:
update Rig_Dates set Est_Rig_Off='25-Mar-18', Est_Rig_On='09-Mar-18' Where XPrime='6913B5020BCECE4CB54370CC1F21A00A'
I run this in Oracle and it works fine. However, when I run it using an OracleCommand, it just locks up the process and I have to kill the code.
After doing more research, I find others that use parameters. I changed my code to:
Dim ocmd As New OracleCommand
ocmd.CommandType = CommandType.Text
ocmd.BindByName = True
Dim oconn As New OracleConnection
oconn.ConnectionString = "DATA SOURCE=xs-bhm-dbd-1:1521/WLCD;USER ID=user;Password=password"
ocmd.Connection = oconn
sql = "update Rig_Dates set "
sql = sql & "Est_Rig_On= :EstRigOn, Est_Rig_Off= :EstRigOff Where XPrime= :XPrime"
ocmd.Parameters.Add("EstRigOn", OracleDbType.Date).Value = Format(CDate(currentRow("Est_Rig_On")), "dd-MMM-yy")
ocmd.Parameters.Add("EstRigOff", OracleDbType.Date).Value = Format(CDate(currentRow("Est_Rig_Off")), "dd-MMM-yy")
ocmd.Parameters.Add("XPrime", OracleDbType.Varchar2).Value = currentRow("XRig_Dates").ToString
ocmd.CommandText = sql
Catch ex As Exception
This also locks up at the ocmd.ExecuteNonQuery() as well. Any suggestions?