简体   繁体   English

如何将wpf应用程序的本地数据库从一台计算机转移到另一台计算机?

[英]How to transfer the local database of wpf application from one computer to other?

I have created a local database in my WPF application,now i want to run the application on some other computer,now how to transfer the local database from one computer to other,and i dont want to create the database manually on other machine? 我已经在WPF应用程序中创建了本地数据库,现在我想在其他计算机上运行该应用程序,现在如何将本地数据库从一台计算机转移到另一台计算机上,又不想在另一台计算机上手动创建数据库? Do we have to convert the database into some .exe file ? 我们是否必须将数据库转换为某个.exe文件? If yes,then how to do this or what is the best approach to implement this? 如果是,那么如何执行此操作,或者执行此操作的最佳方法是什么? My application accesses its own database file in its own directory with this connection string: 我的应用程序使用以下连接字符串访问其自身目录中的自身数据库文件:

System.Environment.CurrentDirectory + @"\Data\" + databaseFileName;

Please explain from scratch as i am new to this?? 请从头解释,因为我是新来的??

I suppose you're running your database in SQL Express. 我想您正在SQL Express中运行数据库。 You can use SQL Server Management Studio (included in most SQL Server installers) to export your database, including data, to a .bacpac file. 您可以使用SQL Server Management Studio (大多数SQL Server安装程序中包括)将数据库(包括数据)导出到.bacpac文件。

In SQL Server Management Studio 2012, right click your database, select Tasks , then Export Data-tier Application... and go through the wizard. 在SQL Server Management Studio 2012中,右键单击您的数据库,选择“ 任务” ,然后选择“ 导出数据层应用程序...” ,然后通过向导。

Then connect SQL Server Management Studio to the SQL Express server of the target machine. 然后将SQL Server Management Studio连接到目标计算机的SQL Express服务器。 You can do that by connecting Management Studio on your machine to the SQL Express running on the target machine (provided that a network connection exists between the two, and the target machine has been properly configured to accept the connection), or by also installing Management Studio on the target machine, then connecting it to the local server ( .\\sqlexpress ). 您可以通过将计算机上的Management Studio连接到目标计算机上运行的SQL Express(前提是两者之间存在网络连接,并且已将目标计算机正确配置为接受连接)来执行此操作,或者通过安装管理目标计算机上的Studio,然后将其连接到本地服务器( .\\sqlexpress )。

Once connected, right click the Databases in the Object Explorer , select Import Data-tier application... , and go through the wizard. 连接后,右键单击“ 对象资源管理器”中的“ 数据库 ”,选择“ 导入数据层应用程序...” ,然后完成向导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM