Results 1 to 2 of 2

Thread: UpdateCommand

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    67

    UpdateCommand

    Hi All,

    I can't seem to get the UpdateCommand that comes with .NET to work. Keep getting runtime error saying:

    An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

    Additional information: Update unable to find TableMapping['Table'] or DataTable 'Table'.

    My code is underneath, If anyone can explain why this is happening and help me put it right i would be grateful!! As its doing my head in.

    Dim db As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\helpdesk.mdb;")
    Dim faultsDA As OleDbDataAdapter = New OleDbDataAdapter("SELECT userName, uniqueIdent FROM faults", db)

    faultsDA.UpdateCommand = New OleDbCommand("UPDATE Categories SET userName = 'testing' ")

    'faultsDA.UpdateCommand.Parameters.Add("@userName", OleDbType.VarChar, 15, "userName")

    Dim faultsDS As DataSet = New DataSet()
    faultsDA.Fill(faultsDS, "faults")

    Dim cRow As DataRow = faultsDS.Tables("faults").Rows(0)
    faultsDA.Update(faultsDS)

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    as far as I could see from yourt code fragment, the problem is quite simple, you are missing:

    faultsda.TableMappings.Add("Table", "YourDatasetName"), which is also born out by the error message you are getting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width