基于C#窗口的便携式应用程序(无解复) [英] Portable Application(without depolyment) in C# windows based

查看:53
本文介绍了基于C#窗口的便携式应用程序(无解复)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据库应用程序...我已经在sql server 2008中创建了数据库..如果我将我的应用程序(代码)单独移动到任何其他系统,它无法工作...(服务器未找到错误即时通讯)所以我需要将代码和数据库一起发送到其他系统,它应该工作......

我该怎么办...

i am having application with database... i have created database in sql server 2008.. if i move my application(code) alone to any other system, it not working...(server is not found error i m getting) so i need to send code along with database to other system and it should work...
how can i do tat...

推荐答案

您必须创建一个文本文件/ xml文件/ .Net配置文件来存储服务器名称/ IP和数据库名称,并将其保存在app目录中。然后你必须在应用启动时阅读它并连接到服务器。



请告诉我它是否有帮助?
You have to create a text file/ xml file/ .Net config file to store server name/IP and database name and save it in app directory. Then you have to read it on app startup and connect to the server.

please let me know it helped or not?


根据您对我的评论的回复,是的,你也可以发送数据库(虽然你不能直接复制)到其他机器。



方法1:

如果要将数据库与数据一起发送,可以使用T-SQL BACKUP命令创建数据库的备份。

2将备份文件复制到目标文件。

3.使用T-SQL RESTORE命令在目标计算机上恢复数据库。

4.数据库恢复后修改连接代码中的字符串指向新服务器和已恢复的数据库。



方法2:

如果您只想复制模式,请生成SQL Server Management Studio中的数据库脚本,并在目标计算机上执行它们。创建数据库后,修改代码中的连接字符串以指向新服务器和已还原的数据库。
As per your reply to my comment, yes you can send database as well (though you cannot copy it directly) to other machine.

Approach 1:
If you want to send the database along with data, you can
1. create the backup of your database using T-SQL BACKUP command.
2. Copy the backup file to your target file.
3. Restore the database on target machine using T-SQL RESTORE command.
4. Once database is restored modify the connection string in your code to point to new server and restored database.

Approach 2:
If you want to copy only the schema, generate database scripts from SQL Server Management studio and execute them on the target machine. Once the database is created modify the connection string in your code to point to new server and restored database.


这篇关于基于C#窗口的便携式应用程序(无解复)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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