使C#程序连接到可以安装在任何计算机上的SQL Server [英] Making a C# Program connected to SQL server that can be installed on any computer

查看:86
本文介绍了使C#程序连接到可以安装在任何计算机上的SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个大问题。我创建了一个C#程序连接到本地系统(在同一台计算机上)上的SQL-Server数据库但我的问题是我想发布我的项目,以便它可以安装在任何计算机上而无需安装完整版的SQL-Server,也无需更改硬编码的连接线。有没有办法做到这一点 ?????在此先感谢。

Hello,
I have a big problem. I made a C# program that connects to a SQL-Server database that is found on the local system (on the same computer) but my problem is that I want to publish my project so that it will be installed on any computer without having to install the full version of SQL-Server and also without having to change the connection line which is hard coded. Is there a way to do this ????? Thanks in advance .

推荐答案

将您的连接字符串移动到app.config文件。然后,您可以更改连接字符串以将SQL Server所在的服务器名称或IP地址放入其中。我通常在连接字符串中使用易于替换的标记来输入用户名和密码供应用程序使用。这些值要么由用户输入,要么加密并与连接字符串分开存储。
Move your connection string to the app.config file. You can then change the connection string to put the server name or IP address that the SQL Server is on in that. I usually use easily replaceable tags in the connection string to put in a username and password for the application to use. These values was either be entered by the user or encrypted and stored separate from the connection string.


这篇关于使C#程序连接到可以安装在任何计算机上的SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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