如何在没有安装 SQL Server 的机器上运行带有 SQL 数据库的应用程序

How to run Application with SQL Database on a machine that dosen#39;t have SQL Server Installed(如何在没有安装 SQL Server 的机器上运行带有 SQL 数据库的应用程序)
本文介绍了如何在没有安装 SQL Server 的机器上运行带有 SQL 数据库的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个应用程序,它有一个滑块,可以显示来自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 数据库的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)