473,388 Members | 1,330 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,388 software developers and data experts.

Copy table schema

Hi:

What is the best way to copy the schema of one DataTable to another ?,
The DataTable.Clone will create a new DataTable

Currently i do it manually

destTable.Clear()
destTable.Columns.Clear()
destTable.Constraints.Clear()

For Each dcSrc In srcTable.Columns
dcDest = destTable.Columns.Add()

dcDest.AllowDBNull = dcSrc.AllowDBNull
dcDest.AutoIncrementStep = dcSrc.AutoIncrementStep
dcDest.AutoIncrementSeed = dcSrc.AutoIncrementSeed
dcDest.AutoIncrementStep = dcSrc.AutoIncrementStep
dcDest.Caption = dcSrc.Caption
dcDest.ColumnMapping = dcSrc.ColumnMapping
dcDest.ColumnName = dcSrc.ColumnName
dcDest.DataType = dcSrc.DataType
dcDest.DefaultValue = dcSrc.DefaultValue
dcDest.Expression = dcSrc.Expression
dcDest.MaxLength = dcSrc.MaxLength
dcDest.Namespace = dcSrc.Namespace
dcDest.Prefix = dcSrc.Prefix
dcDest.ReadOnly = dcSrc.ReadOnly
dcDest.Unique = dcSrc.Unique
Next

There must be an easy way to achieve this, any idea ?

JCVoon
Nov 21 '05 #1
2 13313
Hi,

Table.clone is the best way to copy the Schema of One table into another...............

actually ur quest. is not clear can u explin in detail.what exactly u wan a do?

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #2
Ritesh Jain
Table.clone is the best way to copy the Schema of One table into another...............
actually ur quest. is not clear can u explin in detail.what exactly u wan a do?


Thanks for the info. Here is what i'm trying to do

public sub Caller()
' For some reason i've to create the dt before call MyFunction
dim dt as DataTable = new DataTable
...
MyFunction(dt)
...--------> after the call the dt remain empty (Columns count=0)
end sub
public sub MyFunction(dtDest as DataTable)
dim dtSrc as DataTable
...
dtDest = dtSrc.Clone
...
end sub
In the debuger i can see the dtDest schema, but after return to the
caller the schema gone ! I don't know why
Any idea ?

Thanks
JCVoon


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vojtech | last post by:
Hi, I would like to remark on a problem described by Stephen Livesey almost 3 years ago, about the slowdown he had experienced with an upload of several millions of rows. ...
4
by: Robert Stearns | last post by:
For testing purposes I propose to add a schema (testing, how original) and would like to copy some of my live tables to it, both structure and data. I know I could use something like dump/restore...
2
by: Janning Vygen | last post by:
hi PGurus, i searched the archives and read the docs, because this problem shouldn't be new. But i really don't know what to search for. i am populating a database (v7.4.1) with COPY. Some...
1
by: Mariusz Czułada | last post by:
Hi, In a database I have to create new schemas with exactely the same structure as the default one. Of course, I could reverse a schema with pg_dump, then apply the script to the newly created...
7
by: slitvinov | last post by:
I am learning Relax NG. The problem is that I cannot figure out how to make a schema for a table. In my case I would like to make a table with any name of child elements (columns) but columns...
3
by: islandfong | last post by:
I am trying to copy data from one schema to another schema using TOAD connecting to Oracle 10i. Some of the tables can be copied smoothly but two some of them cannot. There is no error message given,...
1
by: okonita | last post by:
Hi all, I have a need to copy data from one database/schema to a different database schema. Yes, I can use export/import but that is not "elegant". Yes, I can try a redirected Restore from Backup...
1
by: news.magnet.ch | last post by:
Hi all Probably an easy question for an oracle dba or even power user: I would like to copy the data warehouse schema on my laptop for testing and developing our application. - Unfortunately...
2
by: Dev guy | last post by:
Hi all is there a simple command where I can just copy some data from one database server to another? For example, lets say i have two servers that have the same table called "States" If I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...

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.