使用SQL发布C#应用程序不需要SQL Express [英] Publish C# application with SQL no need for SQL express

查看:71
本文介绍了使用SQL发布C#应用程序不需要SQL Express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:



感谢大家的投入。

不幸的是我没有部署经验。

有没有人知道这种情况的教程。

我使用viual studio 2015并且不知道从哪里开始:\

该应用已准备就绪但我知道我将不得不从sql更改为sqlite但不知道如何





谢谢







我在C#中有一个winforms应用程序包含一个sql数据库。

编码之后我现在遇到了问题。

每当我发布应用程序时,我必须在所有客户端计算机上安装SQL server express。

这是唯一的方法吗?我怎样才能使应用程序易于安装,并且唯一的依赖是.net框架?



如果我不得不改变,我不知道的另一件事是连接字符串,在我的情况下它包含完整的文件路径,但在客户端计算机中它不会在那里。



提前谢谢,



我尝试过的事情:



我的骗局字符串是:



Thanks everyone for the input.
Unfortunately i have no experience in deployment.
Does anyone know of a tutorial for this kind of situation.
I use viual studio 2015 and have no clue where to start :\
The app is ready but i know that i will have to change from sql to sqlite probably but dont know how


Thanks

Hi,

I have a winforms app in C# witch contains an sql database.
After the pain of coding i now have a problem.
Whenever i publish the app i have to install SQL server express in all client computers.
Is this the only way? How can i make it so that the app is easy to install and that the only dependecies are .net framework?

Another thing that i dont know if i have to alter is the connection string, in my case it contains the full file path, but in the client computer it wont be there.

Thanks in advance,

What I have tried:

My con string is:

ublic static SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\xxxxx\Documents\Visual Studio 2015\Projects\xxx\xxx\xx.mdf;Integrated Security=True;Connect Timeout=30");

推荐答案

如果您的应用程序使用SqlServer,则无法安排用户安装某种形式的应用程序Sql Server,所以...





将SqlServer Express添加到安装程序的依赖项中......



- 或者 -



考虑使用SqlLite代替。请注意,精简意味着您所期望的 - 您可以做什么以及您可以拥有多少数据的限制,但安装应该不那么痛苦。我不确切地知道这些限制是什么,但你应该能够谷歌它。
If your app uses SqlServer, there's no way around requiring the user to install some form of Sql Server, so...


Add SqlServer Express to your installer's dependencies...

- OR -

Consider using SqlLite instead. Be aware that "lite" means exactly what you would expect - limitations on what you can do and how much data you can have, but the install should be a lot less painful. I don't know precisely what the limitations are, but you should be able to google it.


只要你从你的应用程序使用SQL(或任何其他数据库) ,必须在目标计算机上呈现SQL(以任何方式适合)(如果选择本地数据库而不是数据库服务器)...

最佳解决方案是使安装成为应用程序的一部分设置过程作为依赖...

检查这些:

如何:创建或添加安装项目 [ ^ ]

如何:在Windows Installer部署中安装必备软件 [ ^ ]

演练:使用自定义操作在安装时创建数据库 [ ^ ]
As long as you are using SQL (or any other DB for that matter) from your application, that SQL must be presented (in any way fits) on the target computer (if you choose local DB instead of DB server)...
The best solution is to make the installation part of your application setup process as dependency...
Check these out:
How to: Create or Add a Setup Project[^]
How to: Install Prerequisites in Windows Installer Deployment[^]
Walkthrough: Using a Custom Action to Create a Database at Installation[^]


这里有三件事:

1)从不硬编码连接字符串:它们应始终位于配置文件中,可以根据工作环境进行更改。

2)不要在生产单元中附加数据库 - 这是一个仅适用于SQL Express的开发功能,而不是完整版本。

3)如果您已经为SQL Server编码,那么您需要SQL服务器安装在计算机可以访问的某个地方以便使用数据库:它是基于服务器的系统,不能以独立的方式工作(即没有服务器安装,可用和运行)。



如果你不想在客户端环境中使用SQL服务器,那么使用独立的数据库,如Access或SqLite - 但请注意,如果您需要多用户访问数据库,这些方法无效。
Three things here:
1) Never hard code connection strings: they should always be in configuration files where they can be changed to fit the working environment.
2) Do not Attach databases in production units - it's a development feature that only exists for SQL Express, and not in the full version.
3) If you have coded for SQL server, then you need SQL server installed somewhere that the computer can access in order to use a DB: it''s a Server based system and cannot work in a stand alone way (i.e. without the server installed, available, and running).

If you don't want SQL server in a client environment, then use a standalone database such as Access or SqLite - but be aware that these do not work well if you need multi user access to your database.


这篇关于使用SQL发布C#应用程序不需要SQL Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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