By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

Howto persist a DataTable

P: n/a
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

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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: co**************@yahoo.com

"Plumer" <Ro******@xtra.co.nz> wrote in message
news:04****************************@phx.gbl...
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

Nov 15 '05 #2

P: n/a
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: co**************@yahoo.com

"Plumer" <Ro******@xtra.co.nz> wrote in message
news:04****************************@phx.gbl...
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

Nov 15 '05 #3

P: 2
Hi,

I am in that situation, having the table allready in the SQL server
and the DataTable in the code.
( say a table "Sectors" in a dataset, that needs to replace "TBL_Sectors" in the sql-server )
Could you please show a sample of how its done ?


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: code_writer_2003@yahoo.com

"Plumer" <Roxplume@xtra.co.nz> wrote in message
news:047a01c3586f$20b20e60$a101280a@phx.gbl...[color=blue]
> 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
>[/color]
Jul 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.