SQL Server Express connection string on server not working

試著忘記壹切 提交于 2019-12-25 08:14:54

问题


I have uploaded my project to a server and everything works fine until I try to "log-in" or "register" using EF

Interestingly, on my PC, I have got this to work with SQL Server Express & SQL Server Compact - it just does not work on the server

On the server, I have SQL Server Express installed

Here is the connection string

<add name="DefaultConnection"
     connectionString="data source=(localhost);Integrated Security=SSPI;
                       database=aspnet-MvcDealerConn-20121005200308;
                       AttachDBFilename=|DataDirectory|aspnet-MvcDealerConn-20121005200308.mdf;
                       User Instance=true"
     providerName="System.Data.SqlClient" />

Any help would be much appreciated


回答1:


The whole User Instance and AttachDbFileName= approach is flawed - at best! And it's deprecated, too - don't use it!

The way I would solve this is:

  1. install SQL Server Express (and you've already done that anyway)

  2. install SQL Server Management Studio Express

  3. create your database in SSMS Express, give it a logical name (e.g. DealerConn)

  4. connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:

    Data Source=servername\\SQLEXPRESS;Database=DealerConn;User ID=SomeUser;Pwd=SecretPwd
    

    and everything else is exactly the same as before...

Since it's hosted on a remote server, I also believe you need to most likely provide a separate, explicit User name and password (and you cannot use the Integrated Security=SSPI; tag)



来源:https://stackoverflow.com/questions/13205634/sql-server-express-connection-string-on-server-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!