Is there a way to add the table name automatically using SqlDataAdapter.Fill

102 Views Asked by At

I'm using the IDbDataAdapter Interface to fill my dataSet from a SQLite database. Unfortunatelly the Fill function sets the the DataTable names "Table, Table1. Table2, etc.". I have multiple databases and tables the best way is to fillt the DataTalename automatic with the Fill function. Without thes correct tablenames the .Update function isn't working as well.

  1. In the most manuals there using Fill(table, "tableName") but the only function in the IDbAdapter is the Fill(table) function.
  2. I set the MissingSchemaAction to AddWithKey and the MissingMappingAction to Passthrough

Both doesn't change the table names in the created DataSet.

Is it possible to set the database table names automatic using the .Fill function?

1

There are 1 best solutions below

0
Jorgon98 On

Thanks for helping.

I found a way do solve my problem. Ralf got me the perfect hints.

In my case I define the DataTableName depending on the given sql string. After that I can use the TableMappings from the DataAdpater to map the name to the used Table. In this case I can use the interface to guarantee dependency injection.

And second I forgot to create the specific CommandBuilder object.

Problem soveld :)