I have this code:

Dim cb As OleDb.OleDbCommandBuilder
        Try
            cb = New OleDb.OleDbCommandBuilder(daDocuments)
            daDocuments.Update(CType(bdsDocuments.DataSource, DataTable))
            MessageBox.Show("The data load has finished...", "DBF Load")
        Catch ex As Exception
            MessageBox.Show("1.- " + ex.Message)
        End Try

but, the OleDbCommandBuilder don't create the updatecommand and hence it doesn't work... any ideas?

Dani AI

Generated

A concise troubleshooting note for (and follow‑up to ) with the most common causes and quick checks when an OleDbCommandBuilder doesn't appear to produce an UpdateCommand.

Most likely causes — quick checklist

  • The adapter lacks usable schema/PK information. CommandBuilder derives SQL from the adapter's SelectCommand and the table schema; if the DataTable has no primary key (or the provider doesn't expose key metadata) the builder cannot create proper WHERE clauses.
  • The SelectCommand is not a simple single‑table SELECT (joins, aggregates or complex expressions usually prevent automatic generation).
  • There are no changed rows to send (calling AcceptChanges too early or updating the wrong DataTable will make Update do nothing).
  • CommandBuilder was created before the adapter had schema, or the builder reference was discarded before Update ran.

Concrete steps to diagnose and fix

  • Ensure the DataAdapter has a simple SelectCommand targeting a single table.
  • Populate schema with keys: set the adapter’s MissingSchemaAction to AddWithKey before filling, or call FillSchema so the DataTable gets PrimaryKey information.
  • Verify the table actually has modified rows (use GetChanges() or inspect RowState). Don’t call AcceptChanges() before Update.
  • After constructing the builder, force/inspect generation with GetUpdateCommand() (this reveals the SQL the builder would use). Also check adapter.UpdateCommand is not null before calling Update.
  • If the DBF/OLEDB provider doesn’t expose keys or the SELECT is complex, create and assign a manual OleDbCommand (use positional ? parameters for OleDb) to adapter.UpdateCommand for reliable control.

Diagnostics to log

  • Dump cb.GetUpdateCommand().CommandText and ex.ToString() for any exception details. Confirm the DataTable you pass to Update is the actual table the adapter filled (BindingSource may expose a DataView instead of the original DataTable).

daDocuments.Update(CType(bdsDocuments.DataSource, DataTable))

I think this not right , daDocuments.Update takes two argument one of them is dataset and the other is table

OleDbDataAdapter1.Update(DataSet11, "table_name")

also you can use OleDbCommandBuilder when DataTable maps to a single database table(means database table is not result of join operation)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.