如何将visual studio 2012与sql server 2012数据库连接? [英] How can I connect visual studio 2012 with sql server 2012 database?

查看:259
本文介绍了如何将visual studio 2012与sql server 2012数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mvc4代码构建网站第一种方法。我尝试连接sql server 2012时遇到问题。它没有连接远程sql server数据库。它给了我一个错误webproject重写需要安装在这台计算机上的sql server express。

webconfig中的连接字符串如下:



I am building a website by using mvc4 code first approach. I have a problem when I tried to connect with sql server 2012. it does not connect with remote sql server database. it gives me an error " the webproject rewrite requires sql server express which installed on this computer.
my connection string in webconfig as follow:

<connectionStrings>
     <add name="StoreDataContext" 
         connectionString="Data Source=server=.;
         Initial Catalog=aspnet-Demo-20150421090714;
         Integrated Security=SSPI;
         AttachDBFilename=|DataDirectory|\books.mdf" providerName="System.Data.SqlClient" />

推荐答案

试试这个:

Try this:
<connectionstrings>
     <add name="StoreDataContext"

         connectionString="Server=localhost\SQLExpress;
         Initial Catalog=aspnet-Demo-20150421090714;
         Integrated Security=SSPI;
         AttachDBFilename=|DataDirectory|\books.mdf"

         providerName="System.Data.SqlClient" />


希望它能为您提供帮助,



< add name =dbConnectionStringconnectionString =Data Source = SystemName; Initial Catalog = SampleDB; Persist Security Info = True; Integrated Security = TrueproviderName =System.Data.Sq lClient/>
hope it will help you,

<add name="dbConnectionString" connectionString="Data Source=SystemName;Initial Catalog=SampleDB;Persist Security Info=True;Integrated Security=True" providerName="System.Data.SqlClient" />


这篇关于如何将visual studio 2012与sql server 2012数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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