0

嗨,伙计们,感谢您对事物的所有帮助。我正在使用 linq,我可以很容易地从中获取数据。但我似乎无法更新数据。该程序不会出错,看起来它已经更新,但它没有保存更改。

 Public Function UpdateAlarmsbyKey(ByVal objKey As Integer, ByVal IdNumber As String) As Boolean
    Dim lqAlarms As New linqAlarmDumpDataContext

    Dim GetAlrms = From r In lqAlarms.AlarmDrops _
                   Where r.Key = objKey _
                   Select r


    For Each Calls In GetAlrms

        If Calls.AlarmsHandled = "" Then
            Calls.AlarmsHandled = IdNumber
            Return True
        Else
            Calls.AlarmsHandled = Calls.AlarmsHandled & ":" & IdNumber
            Return True
        End If
    Next
    Return False

End Function
4

1 回答 1

1

尝试调用 -

lqAlarms.SubmitChanges()

更新Calls.AlarmsHandled属性后。此外,您的代码正在循环结果集,但只会更改它找到的第一条记录,这是您想要的行为吗?

于 2011-07-31T17:15:02.123 回答