0

In appsettings.json file, I have this connection string:

"ConnectionStrings": {
    "erasmus": "Data Source=VIPER\\DBSERVER;Initial Catalog=erasmus;Integrated Security=True;"
}

VIPER is my computer's name and DBSERVER is my database server's name. erasmus is the database that I want to connect to.

here is SSMS display

here is all protocols are enabled

I've tried so many different type of connection string styles but it still doesn't work. Also i want to make an user named admin but it won't work either.

Like

"ConnectionStrings": {
    "erasmus": "Data Source=DBSERVER;Initial Catalog=erasmus;Integrated Security=True;"
    },
    "ConnectionStrings": {
        "erasmus": "(local)\\DBSERVER;Initial Catalog=erasmus;Persist Security Info=True;"
    },
    "ConnectionStrings": {
        "erasmus": "Data Source=VIPER\\DBSERVER;Initial Catalog=erasmus;Persist Security     Info=True;User ID=VIPER\\ofadu;"
    ,"ConnectionStrings": {
    "erasmus": "(local)\\DBSERVER;Initial Catalog=erasmus;Persist Security Info=True;User     ID=erasmus; Password=123456;"
    },
    "ConnectionStrings": {
        "erasmus": "DBSERVER,1433;Initial Catalog=erasmus;Persist Security Info=True;"
    },
    "ConnectionStrings": {
    "erasmus": "DataSource=VIPER\\DBSERVER;Database=erasmus;Persist Security Info=True;"
    },
    "ConnectionStrings": {
        "erasmus": "Data Source=DBSERVER;Database=erasmus;Integrated Security=True;"
    }

None are working.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ofaydn
  • 23
  • 1
  • 3
  • The sql server browser service is running on that machine? Also i would advice you to test the connection in the simplest of test apps like a console app with just a SqlConnection and directly hardcoded connectionstring as input for that to get everything out of the way that might be also part of the problem but isn't obvious like getting the connection string from somewhere else currently because there is just a bug in configuration retrieval or so but the connectionstring would be actually correct. – Ralf Mar 15 '23 at 12:55
  • Just confirm: 1) The version of SQL server running on VIPER is not "developer edition" (which only answers on local). 2) VIPER has a firewall opening for TCP and UDP (named pipes). 3) you can connect on local, and this problem is only happening for remote (non-local) connections – tgolisch Mar 15 '23 at 13:21
  • @Ralf I've tried but this time i get `provider: SSL Provider, error: 0` error – ofaydn Mar 16 '23 at 10:37
  • @tgolisch 1) server is developer edition 2) i have closed firewall while server was open 3)server is running on local system and as you can see i enabled all protocols – ofaydn Mar 16 '23 at 10:39
  • In your IIS (or iisexpress, if you are running from VStudio) have you disabled anonymous access, and enabled windows authentication? https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/anonymousauthentication – tgolisch Mar 16 '23 at 12:23
  • @tgolisch oh right, i totally forgot about that. now i enabled anonymous access and i can access without need of a password and user, thanks – ofaydn Mar 16 '23 at 17:37

1 Answers1

0

I suggest that you use connection string with login user. Then be sure that your context name is erasmus. Then change your connection as :

"ConnectionStrings": { 
    "erasmus": "Server=VIPER\DBSERVER;Initial Catalog=erasmus;User ID=sa;password=xxx;MultipleActiveResultSets=True" 

  }

where password should be change to your sql server sa password