Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update requires a valid UpdateCommand when passed DataRow collection

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
Any Clue why I am getting this error message: Thank you for your help as always

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Update requires a valid UpdateCommand when passed DataRow collection with modified rows.

Source Error:


Line 121: 'need to update source db here
Line 122: ' adITechMemo.Update(dsItem, "TechMemoDetails")
Line 123: adITechMemo.Update(dsItem.Tables("TechMemoDetails"))
Line 124:
Line 125: End If

Code:
 Dim i As Integer
        For i = 0 To MemoCounter - 1
            If dsItem.Tables("TechMemoDetails").Rows(i).Item("Status") = "Active" Then
                If dsItem.Tables("TechMemoDetails").Rows(i).Item("ExpireDate") < System.DateTime.Today Then
                    dsItem.Tables("TechMemoDetails").Rows(i).Item("Status") = "Expired"
                    'need to update source db here
                    ' adITechMemo.Update(dsItem, "TechMemoDetails")
                    adITechMemo.Update(dsItem.Tables("TechMemoDetails"))

                End If
            End If
        Next
 
Thank you all, We did it this way and works fine.
Code:
  Dim strStringBuilder As StringBuilder
        strStringBuilder = New StringBuilder
        With strStringBuilder
            .Append("SELECT * FROM tbTM WHERE ")
            .Append(" Status Like 'Active'")
        End With
        Dim cmdITechMemo As OleDbCommand = New OleDbCommand
        cmdITechMemo.Connection = MyTechMemoConn
        cmdITechMemo.CommandType = CommandType.Text
        cmdITechMemo.CommandText = strStringBuilder.ToString
        Dim adITechMemo As New OleDbDataAdapter(cmdITechMemo)


        Dim dsItem As New DataSet
        adITechMemo.Fill(dsItem, "TechMemoDetails")

        Dim MemoCounter As Integer = dsItem.Tables("TechMemoDetails").Rows.Count
        Dim i As Integer
        For i = 0 To MemoCounter - 1
            If dsItem.Tables("TechMemoDetails").Rows(i).Item("Status") = "Active" Then
                If dsItem.Tables("TechMemoDetails").Rows(i).Item("ExpireDate") < System.DateTime.Today Then
                    dsItem.Tables("TechMemoDetails").Rows(i).Item("Status") = "Expired"
                    'need to update source db here
                    ' adITechMemo.Update(dsItem, "TechMemoDetails")
                    'adITechMemo.Update(dsItem.Tables("TechMemoDetails"))

                End If
            End If
        Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top