C#app中的Sql Server连接错误

时间:2021-02-17 03:39:17

My objective was to make a database for general store. Information was very scattered about how to create database and why in that way. So i selected SQL Server Express. Application was made in C# Visual Stduio 2012. Database was created with SQL management Studio. To connect the application with database i used serverexplorer in visual studio and assigned ./sqlexpress

我的目标是为一般商店建立一个数据库。关于如何创建数据库以及为什么以这种方式存在信息非常分散。所以我选择了SQL Server Express。应用程序在C#Visual Stduio 2012中完成。数据库是使用SQL management Studio创建的。为了将应用程序与数据库连接,我在visual studio中使用了serverexplorer并分配了./sqlexpress

Now the problem is that database works fine on my pc but when i deploy application on the clients pc it says

现在问题是数据库在我的电脑上工作正常但是当我在客户端电脑上部署应用程序时它说

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)

Connection String Used connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=pos;Integrated Security=True";

Where i went wrong ? Is database also deployed with published app or i have to do some other steps ? Will i have to install SQL server on client pc too? Note: The application is local. i don't need to transfer data via internet. Let me know according to your experince what is the right way to attach,create and deploy database the right way for this small project because internet is full of guide but there is no where mentioned properly why the specific method is adopted etc

哪里出错了?数据库是否也部署了已发布的应用程序,或者我还需要做其他一些步骤?我是否还必须在客户端PC上安装SQL服务器?注意:该应用程序是本地的。我不需要通过互联网传输数据。让我知道根据你的经验,这个小项目的正确方法是什么是正确的方法来附加,创建和部署数据库,因为互联网充满了指导,但没有正确提到为什么采用特定方法等

1 个解决方案

#1


0  

I solved the issue by download sql server management studio on client pc. I just made a backup of database form my management studio and restored that backup file from clients management studio. And now everything is working

我通过在客户端PC上下载sql server management studio解决了这个问题。我刚从管理工作室备份了数据库,并从客户管理工作室恢复了该备份文件。现在一切正常

#1


0  

I solved the issue by download sql server management studio on client pc. I just made a backup of database form my management studio and restored that backup file from clients management studio. And now everything is working

我通过在客户端PC上下载sql server management studio解决了这个问题。我刚从管理工作室备份了数据库,并从客户管理工作室恢复了该备份文件。现在一切正常