问题描述
我开发了一个应用程序,它有一个滑块,可以显示来自SQL 数据库.我正在使用 Visual Studio 2010 和 Microsoft SQL Server 2008.
I have developed an application that have a slider that showing some data from a SQL Database. I'm using Visual Studio 2010 and Microsoft SQL Server 2008.
事实上,当我在我的个人计算机上部署并运行我的应用程序时,我不会遇到任何问题.当我在另一台机器上尝试时出现问题,问题是应用程序无法连接 SQL 数据库.我试图找出问题的原因,所以我在两台机器上部署后尝试了它,其中一台安装了 SQL Server,另一台没有 SQL Server.该应用程序在安装了 SQL Server 的机器上运行良好,但无法连接到另一台机器上的数据库.
In fact i don't face any problem with my application when i deploy it an run it on my Personal Computer. The problem occurs when i try it on another machine, and the problem is that the application couldn't be connected the SQL database. I tried to figure out the reason of the problem, so i tried it after its deployment on two machines, one of them have a SQL server installed on it, and the other one don't have the SQL Server. The Application worked perfectly on the machine that have the SQL Server installed on it, and it couldn't be connected to the database on the other machine.
这是我在应用程序中使用的连接字符串>>
This is the Connection String i have used in my application>>
connectionString="数据源=.SQLEXPRESS;AttachDbFilename=|DataDirectory|KBank.mdf;集成安全=真;用户实例=真"
connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|KBank.mdf;Integrated Security=True;User Instance=True"
因此,如果有一种方法可以让我在不需要机器安装 SQL Server 的情况下运行应用程序,我将不胜感激.谢谢
so if there is a way that could enable me to run the application without needing the machine to have a SQL Server installed, i would be grateful. Thanks
推荐答案
您需要更改连接字符串以指定安装数据库的计算机.类似于以下内容:
You need to change the connection string to specify the computer the database is installed on. Something like the following:
connectionString="Data Source=machineSQLEXPRESS;AttachDbFilename=|DataDirectory|KBank.mdf;Integrated Security=True;User Instance=True"
connectionString="Data Source=machineSQLEXPRESS;AttachDbFilename=|DataDirectory|KBank.mdf;Integrated Security=True;User Instance=True"
请注意:其他机器上的数据库需要正确配置,才能从其他机器访问.
Please note: The database on the other machine needs to be configured properly so it can be accessed from other machines.
这篇关于如何在没有安装 SQL Server 的机器上运行带有 SQL 数据库的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!