473,805 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto persist a DataTable

Good morning everyone

Using C# I create a bog-standard System.Data.Dat aTable
which I then Add to a System.Data.Dat aset (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 programmaticall y 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 11563
In case when you do not have an existing table in the database, there is
nowhere to persist your programmaticall y created dataset. You must
programmaticall y 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.Dat aTable
which I then Add to a System.Data.Dat aset (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 programmaticall y 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 programmaticall y created dataset. You must
programmaticall y 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.Dat aTable
which I then Add to a System.Data.Dat aset (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 programmaticall y 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 New Member
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_Sector s" 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 programmaticall y created dataset. You must
programmaticall y 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_200 3@yahoo.com

"Plumer" <Roxplume@xtra. co.nz> wrote in message
news:047a01c358 6f$20b20e60$a10 1280a@phx.gbl.. .[color=blue]
> Good morning everyone
>
> Using C# I create a bog-standard System.Data.Dat aTable
> which I then Add to a System.Data.Dat aset (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 programmaticall y 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
486
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 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
2
2480
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 Registry? If the App.config file should be used, reading a configuration setting is trivial, but there appears to be no write methtod. Please post a write method when replying. --
1
5436
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 information to bind mainly to a DataGrid, but I would also like it to persist for the duration that I have a particular page open. I seem to be losing this data either thru postbacks or by the way I have coded it. Does anyone have any suggestions on how...
3
1479
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
1774
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 "generate contract" button on my ASPX page, but I totally lack ideas of how to put the data in the correct places in the html file. I was recommended (actually "do like this" from my boss) to enclose the variable name like this {variable_name} in the...
11
20701
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 t.PrimaryKey.Clear(t.PrimaryKey, 0, 1) If t.Columns.Contains("MYKEY") Then If t.Columns.CanRemove(t.Columns("MYKEY")) Then t.Columns.Remove("MYKEY")
4
1269
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 programatically? What I am doing is this, 1. create dbconn, to tblStates (already done!) 2. User has a dropdown list of states, when they select the state the box next to it with Counties displays only the ones for that state, and on
1
2263
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, or SQLServer) and imports it into a datatable and then on to the dataGridView for the user to see. The thing about that initial datasource is that the application will not know how its columns are formatted up until the data is actually sent...
5
1435
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. But everytime I click the delete or edit button, the gridview disappears again. I guess it is not recreated after a page reload, but what can I do to fix this? This is my code: using System; using System.Data;
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.