简体   繁体   中英

SQL Server Express connection string on server not working

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

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 (eg 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM