473,831 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Colum ns.Clear()
destTable.Const raints.Clear()

For Each dcSrc In srcTable.Column s
dcDest = destTable.Colum ns.Add()

dcDest.AllowDBN ull = dcSrc.AllowDBNu ll
dcDest.AutoIncr ementStep = dcSrc.AutoIncre mentStep
dcDest.AutoIncr ementSeed = dcSrc.AutoIncre mentSeed
dcDest.AutoIncr ementStep = dcSrc.AutoIncre mentStep
dcDest.Caption = dcSrc.Caption
dcDest.ColumnMa pping = dcSrc.ColumnMap ping
dcDest.ColumnNa me = dcSrc.ColumnNam e
dcDest.DataType = dcSrc.DataType
dcDest.DefaultV alue = dcSrc.DefaultVa lue
dcDest.Expressi on = dcSrc.Expressio n
dcDest.MaxLengt h = dcSrc.MaxLength
dcDest.Namespac e = 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 13337
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(dtDe st 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
1217
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. http://www.geocrawler.com/mail/thread.php3?subject=%5BGENERAL%5D+Slowdown+problem+when+writing+1.7million+records&list=12
4
38894
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 for the data and Quest's (BTW this a very nice product) 'create like' function. That would work, but it seems a lot of work for something DB2 should know how to do.
2
2675
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 triggers in the db schema fire on inserts and do some additional data manipulations, which i dont want to take place by running COPY because my data don't need those additional manipulation. Therefor and for performance reasons, i disable all...
1
6397
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 one. The problem is the base schema sometimes changes so I should generate scripts every time. Also I need to do this from a stored function. My question: is it possible to extend (in near future) CREATE SCHEMA syntax with feature like:
7
2294
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 should have the same number of child elements (cell). Say this file is valid <table> <column> <cell/> <cell/> </column>
3
17908
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, TOAD just hangs there and the status bar shows "fetching rows.". The source table and destination table are identical. Anybody knows what's happening?
1
1851
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 but this method has the irritating requirement of pause, set tablespaces and continue, again much manual intervention. What I am most interested in is this: The two databases are in the same instance/server. I want to be able to copy directly from...
1
1615
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 I have a 80GB HD and the DWH contains a few 'tera'. - Fortunately, I don't need the data (ok perhaps a few master data). I need only the schema to avoid 'table not found' errors and so on.
2
21616
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 have all the state names in server1 but want to copy the all the data to Server2, how would I write a command for this? INSERT INTO ..states
0
9793
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
10494
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
10534
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10207
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7748
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
5619
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4416
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
3
3076
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.