Hi All,
Hoping for a bit of help, I have a loop which runs between 5 and 100 updates say. It generates each update from the contents of a datatable (if you look at the code below I'm sure it will make sense).
Stupidly though I could run say this statement
UPDATE calldata SET calldata.status = 1 WHERE calldata.ext = 162
then 10 itterations later
UPDATE calldata SET calldata.status = 5 WHERE calldata.ext = 162
Hence making the first update pointless and a waste of database time. I some how need to check through the datatable to get the last update for each calldata.ext and only run that one, but have no idea how to do this.
Any help would be fab.
Code:Dim sqlupdate As String Dim selstr As String = "SELECT atid, atext, atstatus FROM agentlog WHERE atid >" & after accessconnection.Open() Dim daupt As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(selstr, accessconnection) Dim extnum As Integer Dim status As Integer daupt.Fill(dsup, "callinfo") accessconnection.Close() Dim dr As DataRow For Each dr In dsup.Tables("callinfo").Rows extnum = CInt(dr(1)) status = dr(2) after = dr(0) sqlupdate = "UPDATE calldata SET calldata.status = " & status & " WHERE calldata.ext = " & extnum Dim myCommand As New MySqlCommand(sqlupdate) myCommand.Connection = MySqlConnection myCommand.ExecuteNonQuery() Next dsup.Tables("callinfo").Clear()




Reply With Quote