Can anybody help me on this.
I am just having a simple table testxmlmsg with 4 fields, serno, timestamp, bytexmlmsg, userid.
The serno is set as primary.
I am trying to update the data using the bellow function. No error or exception is coming but the data are not getting updated in the database.
Note that I do not want to use the QueryBuilder.
Thanks in advance for any help.
----------------------------------------------------------------------------------------------------------------------------
Private Sub updateRecord()
Dim connection As IfxConnection
Dim Transaction As IDbTransaction
Dim DataAdapter As IfxDataAdapter = New IfxDataAdapter
Dim UpdateCommand As IfxCommand
Dim SelectCommand As IfxCommand
Try
connection = New IfxConnection(txtConnection.Text)
connection.Open()
Try
Transaction = connection.BeginTransaction()
Try
Dim data As DataSet = New DataSet
UpdateCommand = connection.CreateCommand
SelectCommand = connection.CreateCommand
SelectCommand.CommandText = "SELECT userid FROM testxmlmsg"
SelectCommand.Transaction = Transaction
SelectCommand.Connection = connection
DataAdapter.SelectCommand = SelectCommand
UpdateCommand.Transaction = Transaction
UpdateCommand.Connection = connection
UpdateCommand.CommandText = "UPDATE testxmlmsg SET userid = 2"
DataAdapter.UpdateCommand = UpdateCommand
DataAdapter.Fill(data)
Dim cRow As DataRow
For Each cRow In data.Tables(0).Rows
cRow(0) = 2
Next
DataAdapter.Update(data)
data.AcceptChanges()
Catch exc As Exception
txtUpdateError.Text = exc.Message
End Try
Catch exc As Exception
txtUpdateError.Text = exc.Message
Finally
connection.Close()
End Try
Catch exc As Exception
txtUpdateError.Text = exc.Message
Finally
connection.Dispose()
End Try
End Sub
I am just having a simple table testxmlmsg with 4 fields, serno, timestamp, bytexmlmsg, userid.
The serno is set as primary.
I am trying to update the data using the bellow function. No error or exception is coming but the data are not getting updated in the database.
Note that I do not want to use the QueryBuilder.
Thanks in advance for any help.
----------------------------------------------------------------------------------------------------------------------------
Private Sub updateRecord()
Dim connection As IfxConnection
Dim Transaction As IDbTransaction
Dim DataAdapter As IfxDataAdapter = New IfxDataAdapter
Dim UpdateCommand As IfxCommand
Dim SelectCommand As IfxCommand
Try
connection = New IfxConnection(txtConnection.Text)
connection.Open()
Try
Transaction = connection.BeginTransaction()
Try
Dim data As DataSet = New DataSet
UpdateCommand = connection.CreateCommand
SelectCommand = connection.CreateCommand
SelectCommand.CommandText = "SELECT userid FROM testxmlmsg"
SelectCommand.Transaction = Transaction
SelectCommand.Connection = connection
DataAdapter.SelectCommand = SelectCommand
UpdateCommand.Transaction = Transaction
UpdateCommand.Connection = connection
UpdateCommand.CommandText = "UPDATE testxmlmsg SET userid = 2"
DataAdapter.UpdateCommand = UpdateCommand
DataAdapter.Fill(data)
Dim cRow As DataRow
For Each cRow In data.Tables(0).Rows
cRow(0) = 2
Next
DataAdapter.Update(data)
data.AcceptChanges()
Catch exc As Exception
txtUpdateError.Text = exc.Message
End Try
Catch exc As Exception
txtUpdateError.Text = exc.Message
Finally
connection.Close()
End Try
Catch exc As Exception
txtUpdateError.Text = exc.Message
Finally
connection.Dispose()
End Try
End Sub