I have a small sub-routine to update a table in Oracle database. I am
using OleDBCommand object to update it. It updates one record and then
locks up. What could be the possible reason..?? Here is the code snippet.
Sub UpdateDatabase()
Dim xpath As String
Dim testNodes, itemNode As Object
Dim prdKey As String
Dim timKey As String
Dim fcstUnits As String
Dim i, nodeCount As Integer
Dim OraCmd As OleDbCommand
Try
xpath = "//Product[./@Update = 'true']"
testNodes = dataDOM.SelectNodes(xpath)
nodeCount = testNodes.length
strQuery = "begin "
For i = 0 To nodeCount - 1
itemNode = testNodes(i)
prdKey = itemNode.getAttribute("PRDKey")
timKey = itemNode.getAttribute("TIMKey")
fcstUnits = itemNode.getAttribute("SHPUnits")
strQuery = strQuery & " begin UPDATE FORECAST.FOR_NORM
A "
& _
"SET " & _
"A.FCSTNRMU = '" & fcstUnits & "' " & _
", A.NORMEQVU = '1' " & _
", A.NORM_COMMENT = 'Trial Update' " & _
", A.MODIFIED_BY = 'rsj10517' " & _
", A.MODIFIED_DATE = sysdate " & _
", A.MODIFIED_APP = 'UploadHistory' " & _
"where " & _
"A.PRDKEY = '" & prdKey & "' and " & _
"A.TIMKEY = '" & timKey & "'; end; "
Next
strQuery = strQuery & "end;"
If nodeCount > 0 Then
OraCmd = New OleDbCommand()
With OraCmd
.Connection = OraCon
.CommandText = strQuery
.ExecuteNonQuery()
End With
End If
Catch er As Exception
Response.Write(er.Message)
Finally
OraCmd.Dispose()
OraCon.Close()
End Try
End Sub