none
Update Method of LinqDataSource RRS feed

  • Question

  • I have a table Sample with four fields set as Primary Key: EID, DID, PID and Yr. I have the following Update operation on this table, but it returns the error: "Row not found or changed" even though the row exists in the database. Can someone point out what is wrong in this code?

    Dim EDataSource As LinqDataSource = New LinqDataSource
                        Dim EData As New Dictionary(Of String, String)

                        EDataSource.ContextTypeName = "MySystem.SampleDataContext"
                        EDataSource.TableName = "Sample"
                        EDataSource.DataBind()
                        EDataSource.EnableUpdate = True

                        Dim keyValues As New ListDictionary()
                        Dim newValues As New ListDictionary()
                        Dim oldValues As New ListDictionary()

                        keyValues.Add("EID", CInt(Session("EID")))
                        keyValues.Add("DID", CInt(Session("DID")))
                        keyValues.Add("PID", CInt(Request.QueryString("PID")))
                        keyValues.Add("Yr", Session("Yr").ToString())

                        newValues.Add("AddCove", CDec(Session("FV")))
                        newValues.Add("AddCt", CDec(Session("Pr")))
                        newValues.Add("EStatus", (CDec(Session("FV")) + cove).ToString())
                        newValues.Add("Ct", CDec(Session("Pr")) + ct)

                        oldValues.Add("AddCove", acove)    <--- I am retrieving the old values from the table beforehand.
                        oldValues.Add("AddCt", act)
                        oldValues.Add("EStatus", cove)
                        oldValues.Add("Ct", ct)

                        EDataSource.EnableUpdate = True
                        EDataSource.Update(keyValues, newValues, oldValues)
                        EDataSource.DataBind()
                        EData.Clear()


    Manasi Ranade
    Wednesday, November 9, 2011 8:31 PM

Answers