使用C#或SQL复制Access表结构和约束

编程入门 行业动态 更新时间:2024-10-27 12:30:19
本文介绍了使用C#或SQL复制Access表结构和约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以告诉我如何使用.NET或SQL复制MS Access表的表结构及其所有约束,键等?我已经搜索并发现了一些复制列和类型的方法,但我需要带来约束,如主键。

Can someone tell me how to copy an MS Access table's table structure and all its constraints, keys, and etc. using .NET or SQL? I have searched and found a number of ways of copying the columns and types, but I need to bring across the constraints as well such as primary keys.

我有一个数据库与一堆表,我需要创建(仅结构)的新名称的副本。这需要在C#应用程序内执行,但我不在乎是否使用ADO或SQL,只要我能找到一种方法。

I have a database with a bunch of tables which I need to create copies of (structure only) with new names. This needs to be executed from within a C# application, but I do not care if it is done using ADO or SQL, just as long as I can find a way. Any tips would be greatly appreciated.

推荐答案

您可以导出到同一个数据库,这将创建一个包含所有索引的副本

You can "export" to the same database, which will create a copy with all indexes etc, but not relationships.

// Start a new instance of Access for Automation oAccess = new Access.Application(); // Open a database oAccess.OpenCurrentDatabase(@"z:\docs\test.accdb"); oAccess.DoCmd.TransferDatabase( Access.AcDataTransferType.acExport, "Microsoft Access", @"z:\docs\test.accdb", Access.AcObjectType.acTable, "table1", "newtable",true,false);

更多推荐

使用C#或SQL复制Access表结构和约束

本文发布于:2023-10-20 01:17:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1509400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结构   SQL   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!