'How to connecte to sql sever NET6 visual studio 2022 asp.net mvc project
i try to modify my local db connection (which works fine) in the appsettings.json :
"ApplicationDbContextConnection": "Server=(localdb)\\mssqllocaldb;Database=CateringMilano;Trusted_Connection=True;MultipleActiveResultSets=true"
with the sql server connection :
"ApplicationDbContextConnection": "Data Source=SQL5101.site4now.net;Initial Catalog=db_9b307b_cateringmilano;User Id=db_9b307b_cateringmilano_admin;Password=YOUR_DB_PASSWORD;Trusted_Connection=True;MultipleActiveResultSets=true"
but when i run the project i got a strange error:
local host does not exists..
and also
An unhandled exception occurred while processing the request.
SqlException: Failed to generate SSPI context. Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action wrapCloseInAction)
and also i cannot see the sql server db in visual studio sql explorer..
What do i need to connect my website to my sql sever db? what am i missing to do?
Thanks
Solution 1:[1]
since you are using userid and password for your new server, replace
Trusted_Connection=True;
with
Integrated Security=False;
Solution 2:[2]
Are you be able to connect SQL remotely? If it is working, then please double check your connection string or you can ask your provider about correct connection string that you need to use.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Serge |
| Solution 2 | Douglas Thomas |
