PC Review


Reply
Thread Tools Rate Thread

Creating a physical table through a data table

 
 
=?Utf-8?B?VmFuY2xlaSBNYXRoZXVz?=
Guest
Posts: n/a
 
      22nd Jul 2005
Hello people,

Is there a way to "save" an ADO DataTable in a physical database.
For example, i have an in memory DataTable that i created using ADO.Net
Methods and i want to create a physical table in the database with the same
attributes of my DataTable during run-time.

Thanks
Vanclei
 
Reply With Quote
 
 
 
 
W.G. Ryan MVP
Guest
Posts: n/a
 
      22nd Jul 2005
If the table already exists (structurally) in the back end.

Set the AcceptChangesDuringFill property of your dataadapter to false, and
then Fill your datatable. Now, configure an adapter pointing to where you
need the data to go and call update. It will trasnfer it into the
destination table.

Otherwise, you're going to have to fire a DDL statement to create the table.
You can get the schema of the datatable object though and build your DDL
Statement from there.
"Vanclei Matheus" <(E-Mail Removed)> wrote in
message news:68CC7ACA-7DFD-45A0-B1C6-(E-Mail Removed)...
> Hello people,
>
> Is there a way to "save" an ADO DataTable in a physical database.
> For example, i have an in memory DataTable that i created using ADO.Net
> Methods and i want to create a physical table in the database with the
> same
> attributes of my DataTable during run-time.
>
> Thanks
> Vanclei



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      23rd Jul 2005
Vanclei,

If you want to know if you can use the schema information of your own
created datatable to create a table with information in your database with
by instance one statement, than the answer is "No"

If you want to use that information than it is as much work as if you use
the information direct that you had used to create the table.

I hope this helps,

Cor


 
Reply With Quote
 
Sahil Malik [MVP]
Guest
Posts: n/a
 
      25th Jul 2005
There is no one shot method.

There is a straightforward programmatic way to do this, i.e.

1. First create the table by using ExecuteNonQuery with a Create table
statement.
2. Then run a loop with another DbCommand (SqlCommand?) that acts row by
row.

The above approach might be terribly slow but is a fully managed solution.

Your other choice is to export the DataTable to XML and then use a SQL
Server import process.
This approach will be quicker, but it will be not fully managed. This will
also require you to first create the table.

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.ma.../13/63199.aspx
----------------------------------------------------------------------------




"Vanclei Matheus" <(E-Mail Removed)> wrote in
message news:68CC7ACA-7DFD-45A0-B1C6-(E-Mail Removed)...
> Hello people,
>
> Is there a way to "save" an ADO DataTable in a physical database.
> For example, i have an in memory DataTable that i created using ADO.Net
> Methods and i want to create a physical table in the database with the
> same
> attributes of my DataTable during run-time.
>
> Thanks
> Vanclei



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko Microsoft Excel Misc 1 5th May 2010 08:22 AM
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko Microsoft Excel Misc 0 5th May 2010 12:21 AM
How can I detail Pivot Table data without creating a table (Excel2007)? Skeletiko Microsoft Excel Discussion 0 15th Apr 2010 11:56 AM
I determinate the data type of a physical table field ad Microsoft C# .NET 1 5th Dec 2006 06:54 PM
Creating new table using another table data. =?Utf-8?B?RG9ubnk=?= Microsoft Access Getting Started 1 20th Nov 2004 02:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:25 AM.