-1

I made a asp.net core application and I need to host it on local PC with local DB. For test I deploy and host it on my PC with IIS and it's working without problem but only with online DB, when I change connection string to my local DB I got this error: error with local database

and here is my connection string for online ( working normally) and local db ( don't work when deploy, work in visual studio)

connection strings

what I need to install/change to host my app on local PC with local DB

next24
  • 1
  • 2
  • So application and database runs on the same computer but if application tries to connect to local database it crashes. And it its connect to online db it works fine. Am I getting it right? – Chetan Mar 29 '18 at 15:21
  • Yes, but only when deploy and host app with IIS – next24 Mar 29 '18 at 15:25
  • Looks like the user account under which the iis runs doesn't have access to local sql server. Instead of `Trusted_Connection =true` try putting username and password of the actual database user in the connection string. – Chetan Mar 29 '18 at 15:29
  • I tried it now but nothing, same error again – next24 Mar 29 '18 at 15:48

3 Answers3

0

You should use SQL Server Express for this, not Localdb. Localdb is for VS and single desktop app use only .

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • and how do I need to set connection string for sql express and IIS manager I just need to deploy and use my app on local PC ( no internet connection) – next24 Mar 29 '18 at 15:38
0

Today I tried with sql express and localDB instance but I don't know how to set it. I was try some variations but unsuccessfully, I can't find tutorials for that.

Is it possible at all to host ASP.net core MVC to IIS and use local database ? My app will run on PC without connection to the internet so I need to put database locally

next24
  • 1
  • 2
0

I solve my problem but forget to post here

I need to create new sql user with privileges to my db and set connection string like this:

    "Name": "Server=localhost; Database=myDB; Trusted_Connection=false; MultipleActiveResultSets=false;User ID=UserName; Password=UserPass;"
next24
  • 1
  • 2