Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. OleDbDataAdapter Update

OleDbDataAdapter Update

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdata-structuresdebugging
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Toni78
    wrote on last edited by
    #1

    I am new to ASP.NET and ADO.NET and I am having some problems with the following code so I was hoping that someone would be able to help me. When I run the page that contains this code I get this error: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. 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 36: next i Line 37: Line 38: oDataAdapt.Update( dsDataSet ) Line 39: Line 40: End Sub I have looked at the Update method of OleDbDataAdapter class but I cannot seem to pinpoint the problem. Am I missing some function that must be ran before I run Update?

    Dim logConn As OleDbConnection
    Dim oDataAdapt As OleDbDataAdapter
    Dim dsDataSet As New DataSet

    'the connection string is here somewhere

    Dim strSQL As String
    strSQL = "SELECT * FROM tblPracticum WHERE PlacementNo = " & Session("PlacementNo")
    oDataAdapt = New OleDbDataAdapter( strSQL, logConn )
    oDataAdapt.Fill( dsDataSet )

    'Populate the fields with the record information that was pulled from the dbase
    Dim i As Integer
    For i = 1 to 5
    dsDataSet.Tables.Item(0).Rows(0).Item("txtBox" & i) = Session("txtBox" & i )
    next i
    oDataAdapt.Update( dsDataSet )

    // Afterall, I realized that even my comment lines have bugs

    M 1 Reply Last reply
    0
    • T Toni78

      I am new to ASP.NET and ADO.NET and I am having some problems with the following code so I was hoping that someone would be able to help me. When I run the page that contains this code I get this error: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. 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 36: next i Line 37: Line 38: oDataAdapt.Update( dsDataSet ) Line 39: Line 40: End Sub I have looked at the Update method of OleDbDataAdapter class but I cannot seem to pinpoint the problem. Am I missing some function that must be ran before I run Update?

      Dim logConn As OleDbConnection
      Dim oDataAdapt As OleDbDataAdapter
      Dim dsDataSet As New DataSet

      'the connection string is here somewhere

      Dim strSQL As String
      strSQL = "SELECT * FROM tblPracticum WHERE PlacementNo = " & Session("PlacementNo")
      oDataAdapt = New OleDbDataAdapter( strSQL, logConn )
      oDataAdapt.Fill( dsDataSet )

      'Populate the fields with the record information that was pulled from the dbase
      Dim i As Integer
      For i = 1 to 5
      dsDataSet.Tables.Item(0).Rows(0).Item("txtBox" & i) = Session("txtBox" & i )
      next i
      oDataAdapt.Update( dsDataSet )

      // Afterall, I realized that even my comment lines have bugs

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, You need to specify a valid UpdateCommand for the adapter object, for more information see: Updating the Database with a DataAdapter and the DataSet[^]

      T 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, You need to specify a valid UpdateCommand for the adapter object, for more information see: Updating the Database with a DataAdapter and the DataSet[^]

        T Offline
        T Offline
        Toni78
        wrote on last edited by
        #3

        Thank you for your reply minhpc_bk. I was able to find the article that you listed but now I have another problem about the database not being updatable or something like that. I am looking into different articles but so far I've had no luck. In any case, thank you for taking the time to respond. I really appreciate it. // Afterall, I realized that even my comment lines have bugs

        M 1 Reply Last reply
        0
        • T Toni78

          Thank you for your reply minhpc_bk. I was able to find the article that you listed but now I have another problem about the database not being updatable or something like that. I am looking into different articles but so far I've had no luck. In any case, thank you for taking the time to respond. I really appreciate it. // Afterall, I realized that even my comment lines have bugs

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Hi Toni, Which database are you using? I guess it's Access, right? If so, you need to grant the ASP.NET worker process identity(it's normally the ASPNET account) the write permission to the db file. You might want to check out the KB [Process and request identity in ASP.NET](http://support.microsoft.com/default.aspx?scid=KB;EN-US;q317012c)[[^](http://support.microsoft.com/default.aspx?scid=KB;EN-US;q317012c "New Window")] for more information.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups