PDA

Click to See Complete Forum and Search --> : UpdateCommand


deano1
May 21st, 2002, 10:10 AM
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)

RichardAtherton
May 25th, 2002, 03:59 AM
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