内容 |
还不知道S2012是怎么连接sql数据库的吗?那么还不知道的朋友赶快来学习一下小编带来的VS2012连接sql数据库的操作方法吧,希望可以帮助到大家哦。 首先,打开自己的数据库,这里用的“SQLServer 2008R2”,打开自己的数据库后,找到自己数据库的名称,如图所示,想要连接名为“laboratory”的数据库,以这个数据库作为示范。  打开自己的vs2012,在里面的菜单里面选择“视图”,在“视图”下面选择“服务器管理资源”,如图所示:  在出现的界面中,我们选择“数据链接”,在“数据链接”这个选项中鼠标右键他,我们选择“添加链接”,如图所示:  选择“添加链接”后出现这个面板,我们把服务器选择“(local)”直接书写进去,“登陆到服务器”选择“使用SQL Server登陆”,如图所示:  在“连接到数据库”一栏中我们选择自己刚刚想要选择的数据库名称,“laboratory”即可,如图所示~  选择完毕后,我们点击刚刚的“laboratory”,右键属性即可,如图所示:  右键点击“属性”后,在软件vs2012的右边出现这个界面,我们直接选择“连接字符串”,复制后面的一大串代码即可,如图所示:  在“webconfig”配置界面中,我们把刚刚复制的代码替换其中的“key”字符串里面的“value”值即可:  替换字符串以后,我们需要把刚刚的“Password”改成自己的数据库密码,用户名改成自己的用户名即可,如图所示:  以上就是小编带来的VS2012连接sql数据库的操作方法,有需要的朋友不要错过哦。 |