导出Visual Studio项目WITH数据库 [英] Export Visual Studio project WITH database

查看:83
本文介绍了导出Visual Studio项目WITH数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我有一个适用于数据库的Visual Studio 2010项目。这很简单,使用表单将联系信息添加到数据库并可以从数据库中读取信息。只要它在我的笔记本电脑上,那就太好了,很好。



我该怎么办才能让它在其他地方可读机器?

我是否以某种方式使用项目导出数据库(我认为它会自动执行此操作,因为我在VS中添加了数据库),或者我是否必须更改连接字符串?



谢谢!

解决方案

安装设备时,必须在perticulkar PC上创建数据库实例你必须在你的设置中添加先决条件作为sql实例然后编写代码,它将自动获取连接字符串,其中包含PC名称& sql实例名称



reffer以下链接

Visual Studio安装项目中添加.NET Framework的先决条件 [ ^ ]





http: //social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/b32f7782-c905-4577-ab7c-a0827803eea3/ [ ^ ]


< blockquote>请在StackOverflow上查看此答案:部署Visual Studio 2010数据库项目 [ ^ ]



< pre lang =text>是的,您可以从Visual Studio部署到不同的计算机。您也可以使用VSDBCMD从命令行执行此操作。您可以创建一个WIX项目,为其他人提供一个安装它的向导。

如果您可以从开发PC连接到目标数据库,则可以部署到它。要执行此操作:

从解决方案配置下拉列表中选择另一个配置。通常,项目将随附调试和发布。您可以添加另一个配置,以允许您通过单击配置管理器部署到各种目标。


右键单击项目并选择属性,或者只需双击项目下的属性。
单击部署选项卡。请注意,Configuration:下拉列表显示与active相同的选定配置。
将部署操作更改为创建部署脚本(.sql)并部署到数据库。
在目标连接字符串旁边,单击编辑,然后使用该对话框创建与目标数据库的部署连接。
如果不同,请填写目标数据库名称。
对于每个部署配置(例如,调试,发布等),您可能需要单独的部署配置文件。如果单击新建,则可以为当前配置创建一个。新文件将打开,您可以检查和取消选中有关部署的重要信息。


注意:如果选中始终重新创建数据库,则脚本将DROP并创建数据库。您将丢失目标上的所有数据!小心你在这里选择的内容。大多数人都将未经检查的内容留给了生产目标。我检查它是否为开发或本地,因为我想要一份新的副本。
将更改保存到文件和属性。
要部署到目标,请确保选择正确的配置。单击构建/部署[我的数据库名称]。您可能应该尝试这一点,以便在实际环境中尝试之前熟悉它的工作原理。
良好实践:为生产构建类似的环境(Staging)并首先在那里进行部署,以测试部署,并在部署之前始终备份数据库,以防出现问题。



欲了解更多信息,请参阅:



使用数据库项目(http://msdn.microsoft.com/en-us/ library / xee70aty.aspx)



演练:将现有数据库模式置于版本控制之下(http://msdn.microsoft.com/en-us/library/aa833194 .aspx)



Visual Studio 2010 SQL Server数据库项目(http://msdn.microsoft.com/en-us/library/ff678491.aspx)

这取决于!



主要取决于你使用的是哪个数据库系统:例如,如果你使用SQL服务器或MySQL,那么目标机器需要访问服务器实例,或者有人必须在机器上安装整个(巨大的)数据库管理系统,或者它可以通过机器访问的机器网络。



如果你使用SQLite或SqlCE,那么你只需要包含文件和相关的DLL。



如果您使用的是MySQL的SQL服务器并且这是一个单用户数据库,那么我强烈建议您更改您的应用程序以使用SQLite或SqlCE。


Hello

I have a Visual Studio 2010 project that works with a database. It''s simple enough, using the form it adds contact info to the db and can read the info from the db. That''s all nice and peachy, as long as it''s on my laptop.

What should I do to make it ''readable'' on other machines?
Do I somehow export the database with the project (I thought it would do this automatically as I added the db within VS itself), or do I have to change the connection string?

Thank you!

解决方案

you have to create database instance on that perticulkar PC when you install your setup for that you have to add prerequisite as sql instance in your setup then write code which will get connection string autometically which contains PC name & sql instance name

reffer following links
Add Prerequisites of .NET Framework in Visual Studio Setup Project[^]


http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/b32f7782-c905-4577-ab7c-a0827803eea3/[^]


Please take a look at this answer on StackOverflow: Deploy Visual Studio 2010 Database Project[^]

Yes, you can deploy from Visual Studio to different machines. You can also do it from the command line, using VSDBCMD. And you can create a WIX project to give a wizard for others to install it with.

If you can connect to the target database from your dev PC, you can deploy to it. To do this:

Select another Configuration from the Solution Configuration drop down. Normally, the Project will come with "Debug" and "Release" baked in. You can add another configuration to allow you to deploy to various targets by clicking "Configuration Manager."


Right-click your Project and select 'Properties', or simply double-click Properties under the project.
Click the Deploy tab. Notice that the Configuration: drop-down shows the same selected configuration as "active."
Change the Deploy Action to "Create a deployment script (.sql) and deploy to the database."
Next to Target Connection String, click "Edit" and use the dialog to create your deployment connection to the target database.
Fill in the Target database name, if different.
For each Deployment Configuration (e.g., Debug, Release, etc.), you will probably want a separate Deployment configuration file. If you click "New," you can create one for the current configuration. The new file will open, and you can check and uncheck important things about the deployment.


Note: If you check Always re-create the database, the script will DROP and CREATE your database. You will lose all your data on the target! Be careful what you select here. Most people leave that unchecked for a Production target. I check it for Development or Local because I want a fresh copy there.
Save your changes to the file and to Properties.
To deploy to the target, be sure to select the correct Configuration. Click Build/Deploy [My Database Name]. You probably should experiment with this so you are familiar with how it works before trying it on a live environment.
Good practices: build a similar environment to production ("Staging") and deploy there first, to test the deployment, and always back up the database before deploying, in case something goes wrong.


For more info, please see:

Working with Database Projects (http://msdn.microsoft.com/en-us/library/xee70aty.aspx)

Walkthrough: Put an Existing Database Schema Under Version Control (http://msdn.microsoft.com/en-us/library/aa833194.aspx)

Visual Studio 2010 SQL Server Database Projects (http://msdn.microsoft.com/en-us/library/ff678491.aspx)


That depends!

What it primarily depends on is which database system you used: if you used SQL server or MySQL for example, then the destination machine either needs access to an server instance, or someone will have to install the whole (huge) DB management system on the machine, or a machine it has access to via a network.

If you used SQLite or SqlCE on the other hand, then you just need to include the file, and the relevant DLLs instead.

If you did use SQL server of MySQL and this is a single user database, then I would strongly recommend changing your app to use SQLite or SqlCE instead.


这篇关于导出Visual Studio项目WITH数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆