问题描述
我有一个Microsoft SQL Server数据库,该数据库会定期更新数据.我想使用C#将所有表(最好是关系)的数据库存储到新的Microsoft Access(.accdb)文件中.
I have a Microsoft SQL Server database which is updated with data regularly. I would like to store this database with all tables (and preferrably relationsships) to a new Microsoft Access (.accdb) file using C#.
SQL Management Studio已安装在系统上,因此我认为一种解决方案可以是调用BCP( http://msdn.microsoft.com/zh-cn/library/ms162802.aspx ),但是在这种情况下,我还没有弄清楚如何正确使用它.我想有很多更好的方法可以做到,而无需使用BCP.
SQL Management Studio is installed on the system so I think one solution could be to invoke BCP (http://msdn.microsoft.com/en-us/library/ms162802.aspx) from the code, but I haven't figured out how to use it correctly in this case. I guess there are much better ways doing it without using BCP though.
任何人都可以推荐实现这一目标的方法吗?
Can anyone recommend a way to achieve this?
谢谢
推荐答案
您可以在Access中导入MSSQL数据.有关更多信息: http://office.microsoft.com/zh-CN/access-help/import-or-link-to-sql-server-data-HA010200494.aspx
You can import MSSQL Data in Access; More info on: http://office.microsoft.com/en-us/access-help/import-or-link-to-sql-server-data-HA010200494.aspx
更新:
或者,您可以使用sqldataadapter选择所有表以将所有内容存储在数据集中,请参见:
Alternately you can select all tables using sqldataadapter to store everything in a dataset, see: Obtaining a dataset from a SQL Server database
从那里可以将数据集另存为访问数据库文件,请参见: C#访问数据库的数据集
From there on you can save the dataset as a access database file, see: C# Dataset to Access DB
也许这更符合您的问题.
Maybe this is more inline with your problem.
这篇关于将MSSQL数据库导出到MS Access .accdb文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!