帮助连接到SQL数据库添加到Winforms Application C# [英] Help Connecting to SQL Database added to Winforms Application C#

查看:83
本文介绍了帮助连接到SQL数据库添加到Winforms Application C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是数据库部署的新手。我在Visual Studio中将数据库添加到我的C#项目中,并在数据源下显示。在我的开发机器上,它连接到SQL数据库,但我猜不是添加到我的项目中的那个,因为当我将它部署到另一台机器时它不起作用。我是否需要更改连接字符串才能连接到我的应用程序中的数据库?



我当前的连接字符串是:

< pre lang =c#> public static string sConnStr = Data Source = .; Integrated Security = true; Initial Catalog = db_sms_console;;





我在其他系统上运行应用程序时遇到错误:


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



任何帮助都将非常感激。

解决方案

您必须在数据源中指定服务器名称



从这里开始:http://www.connectionstrings.com/sql-server/ [ ^ ]


I am new to database deployment. I added the database to my C# project in visual studio and it s displaying under Data Sources. On my development machine it connects to the SQL database, but I'm guessing not to the one added to my project because it is not working when I deploy it to another machine. Do I need to change my connection string for it to connect to my database within my application?

my current connection string is:

public static string sConnStr = "Data Source=.;Integrated Security=true;Initial Catalog=db_sms_console;";



I get the error when running the application on any other system other than mine:

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: named pipes provider, error: 40 - could not open a connection to SQL Server.)

Any help wouldbe greatly appreciated.

解决方案

You have to specify the "server" name in "Data Source"

Start here : http://www.connectionstrings.com/sql-server/[^]


这篇关于帮助连接到SQL数据库添加到Winforms Application C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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