开发者

vb.net linq update Data

开发者 https://www.devze.com 2023-03-25 10:23 出处:网络
Hi Guys thanks for all the help on things. Im using linq and im able get get data ouf of it realy easy. but i seem to not be able to update the data. the program does not error on it and it looks like

Hi Guys thanks for all the help on things. Im using linq and im able get get data ouf of it realy easy. but i seem to not be able to update the data. the program does not error on it and it looks likes it has updated but it does not save te changes.

 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


Try calling -

lqAlarms.SubmitChanges()

after you've updated the Calls.AlarmsHandled property. Also, your code is looping round a result set but will only change the first record it finds, is that the behaviour you wanted?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号