如何在visual stadio 2015中连接到旧版本数据库 [英] How do I connect to old version database in visual stadio 2015

查看:98
本文介绍了如何在visual stadio 2015中连接到旧版本数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visual studio2015中调试了一个基于Windows的项目,但objet sqlconnection中的面部错误是打开的



我尝试了什么:



我更改连接字符串,attachdbfilename,用户实例...但不能连接到数据库并打开

解决方案

首先不将数据库附加到SQL - 它只是用于开发的特殊,并且在非Express版本的Sql Server中根本不起作用。您应该在SQL中创建数据库并让它管理它,而不是尝试根据需要附加文件。



其次,从您的连接字符串开始 - 尝试设置一个VS中与服务器资源管理器窗格的连接:

1)打开服务器资源管理器。

2)右键单击数据连接并选择添加连接

3)在随后的对话框中,选择您的数据源和数据库,指定安全信息,然后按测试连接按钮。

4)当连接正常时,按确定

5)在服务器资源管理器窗格中突出显示数据库,然后查看属性窗格。将显示一个连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中。



直到您有了工作,您的C#或VB基于代码永远不会起作用。


关于AttachDBFileName:

Quote:

将在Microsoft SQL Server的未来版本中删除此功能。避免在新的开发工作中使用此功能,并计划修改当前使用此功能的应用程序。

此处提供更多信息:>坏习惯:使用AttachDBFileName - SQL Sentry [ ^ ]


I debug a windows based project in visual studio2015,but face error in objet sqlconnection be open

What I have tried:

I change connection string,attachdbfilename,user instance ... but cannot conect to database and open

解决方案

Start by not attaching databases to SQL - it's a "special" for development only, and doesn't work at all in non-Express versions of Sql Server. You should create the DB within SQL and let it manage it, not try to attach a file as needed.

Second, start with your connection string - try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.

Until you have that working, your C# or VB based code is never going to work.


About AttachDBFileName:

Quote:

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

More information here: Bad habits : Using AttachDBFileName - SQL Sentry[^]


这篇关于如何在visual stadio 2015中连接到旧版本数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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