473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Howto persist a DataTable

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
3 11527
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
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
Tzumer
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Plumer | last post by:
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...
2
by: Dan Sikorsky | last post by:
Should application data be read and written to the Registry to persist state, or should the App.config file be used? If the Registry should be used, what .NET class reads and writes the...
1
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable...
3
by: Alex | last post by:
How can I retrieve a DataRow from the DataGrid in the update handler? Can I do this or do I need to construct one?
4
by: Vlady | last post by:
Hello. I recently built an ASP.NET "financial" application. I got to the point where I have a HTML template (a contract) which needs to be filled with various data from the database. I put a...
11
by: Martin | last post by:
Hi, I understand you must first remove the constraint. The following bit does not work (where t is a DataTable). It gives a 'reference not set to an object' error ...
4
by: DEWright_CA | last post by:
Hi Everyone! I am working on a project in C# and have a table the contains state info, plus a variety of other info that I will reference from another dropdown list. How can I do this...
1
by: BStrick | last post by:
I would like to know what may be the "Best" way to approach with problem. I have an application that I created to transfers data dynamically from an unknown source (ie maybe Excel, Access, XML,...
5
by: Marc | last post by:
Ok, I am studying dot net, and I have a probably newbee sort of question again. I have made a form and a button that fills the gridview on the form. I also want to make a delete and edit button....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.