简体   繁体   中英

Editing a DataTable Row & Column VB.NET

I am dynamically building a DataTable and just adding rows to it as my events fire.

What I wish to do is then update a particular row that is found based on the entry in the first column. I do not wish to do a For Each and then IF statement because my For Each could potentially cycle through tones of rows that it isn't interested in.

Help :/

'Call Recorder Variables
Dim retelltbl As New DataTable

Public Sub AlertingEx(direction As Integer, party As Integer, 
        sendingComplete As Integer, csid As Integer, auditType As Integer, 
        signallingMode As Integer, reservedParam7 As Integer, 
        reservedParam8 As Integer, reservedParam9 As Integer, 
        reservedParam10 As Integer, callid As String, 
        calledNumber As String, callingNumber As String, timestamp As String, 
        reservedString5 As String, reservedString6 As String)

    retelltbl.Rows.Add(New Object() {Date.Now, callid})
    Console.WriteLine("Alerting: " & callid & " | " & calledNumber & " | " & callingNumber)
End Sub

When a receive a connected Event I wish to then update the retelltbl using the callid to link the 2.

Cheers,

Ok, if I am understanding you correctly, you need to find a single row in a DataTable, but you don't want to loop through each row to find it. This is perfectly understandable. And there IS a way to do it, assuming that you have a way to identify a unique row. From looking at your code, I'm guesing that "callid" might be a column that will uniquely identity each row? Is so, you could do something like this:

Dim MyFilter As String = "callid=" & callid
Dim MyRows As DataRow() = retelltbl.Select(MyFilter)

This would give you an array of DataRows that match the criteria in your filter. Assuming each callid is unique, the collection would only contain one row, in which case you would access it with:

MyRows(0)

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM