Howto persist a DataTable

  • Thread starter Thread starter Plumer
  • Start date Start date
P

Plumer

Good morning everyone

Using C# I create a bog-standard System.Data.DataTable
which I then Add to a System.Data.Dataset (At the moment
I'm in the guess-and-test phase so the table has only
one field called "ID" which is Int32.)

I need to save this table to an SQL Server database. The
Dataset/DataAdapter approach does not seem to provide for
this requirement. The logic appears to be based on the
expectation of the presence of a preexisting db structure
which doesn't change (or which can't be changed in ways
that are 'persistable').

I'm probably missing something here so could someone
please steer me to a way to get a programmatically created
table (DataTable) saved to a database.

I have tried (unsuccessfully) using the XML approach (the
output works fine but the import fails).

Any ideas?

TIA

Plumer
 
In case when you do not have an existing table in the database, there is
nowhere to persist your programmatically created dataset. You must
programmatically create a table(s) in your database that is identical to
your dataset, then save your dataset into it.
If you need code examples, let me know: (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top