目前我正在使用VB.NET开发一个系统。我有UPDATE的以下查询。在SQL Developer
中运行时,此查询有效UPDATE CCS2_TBL_INSPECTION_STANDARD SET CCSEQREVITEM = :CCSEQREVITEM,
CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY') WHERE
CCSEQID = :CCSEQID
但是当我尝试在VB.net中应用此查询时,它无法正常工作。实际上,此更新功能的流程是可行的,但是当我更新数据时,它无法正常工作。例如,我想要更新名称从'Ali'到'Abu',当我点击更新按钮时,弹出窗口显示“更新成功”但名称不会更改为'Abu',它仍然是'Ali'。执行时没有错误。谁知道?在VB.net代码下面:
Protected Sub editInspectionRev(eqid As String)
Dim xSQL As New System.Text.StringBuilder
xSQL.AppendLine("UPDATE CCS2_TBL_INSPECTION_STANDARD")
xSQL.AppendLine("SET")
xSQL.AppendLine("CCSEQREVITEM = :CCSEQREVITEM, CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY')")
xSQL.AppendLine("WHERE CCSEQID = :CCSEQID")
Using cn As New OracleConnection(ConString)
cn.Open()
Dim cmd As New OracleCommand(xSQL.ToString, cn)
cmd.Connection = cn
cmd.Parameters.Add(":CCSEQREVITEM", txtRevContent.Text)
cmd.Parameters.Add(":CCSREVEFFECTIVEDATE", txtRevEffDate.Text)
cmd.Parameters.Add(":CCSEQID", eqid)
cmd.ExecuteNonQuery()
cn.Close()
End Using
success3.Visible = True
DisplayRevisionDetails()
End Sub
答案 0 :(得分:1)
问题是你已经执行了交易但未能COMMIT
。有一个正确的方法here的例子,我将在下面部分再现后代
Using connection As New OracleConnection(connectionString)
connection.Open()
Dim command As OracleCommand = connection.CreateCommand()
Dim transaction As OracleTransaction
' Start a local transaction
transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
' Assign transaction object for a pending local transaction
command.Transaction = transaction
...
command.ExecuteNonQuery()
transaction.Commit()
观察我们已经开始事务,然后在执行后提交它。