Where is the database used by IIS

Asked

Viewed 116 times

0

I have a project created in c# (ASP.NET 5 MVC) that uses an SQL database.

I published the project to a folder on the local server and created a database with Sql Server Management Studio (SSMS).

All goes well on IIS, however, the database being used by IIS is not the one I created on SSMS. If I go to the Link Chains menu on the IIS I can see that it points to the database I created, however, the data is not being recorded in that database.

To try to understand what was going on, I deleted all the databases that appeared to me listed in the SSMS, however the application continued to work perfectly. So I did a search on the server for MDF type files but I did not see any.

Connection string:

<add connectionString="Server=(localdb)\MSSQLLocalDB;Database=outraDB;Integrated Security=true" name="DefaultConnection" providerName="System.Data.SqlClient" /> 

Does anyone have any idea what’s going on ?

  • 1

    How the database connection is made?

  • The connection is made through a string Connection.

  • Can you show the Connection string or does it contain protected information? Because probably the cause of this behavior, which you described, is there.

  • 1

    Present your connection string... when you find it you will see that this question makes no sense.

  • <add connectionString="Server=(localdb)\MSSQLLocalDB;Database=outraDB;Integrated Security=true" name="DefaultConnection" providerName="System.Data.SqlClient" /> Como disse anteriormente esta connection string aponta para uma base de dados que eu criei, but if I delete this database the app works on it and contains the previously saved data.

  • If your application is not pointing to the base outraDB in the (localdb)\MSSQLLocalDB is because you are using another connection string configured elsewhere... or you are waiting for the server to access your local machine while it is looking at itself...

Show 1 more comment

1 answer

3

You should not use localDB in the production environment, it is a resource intended only for the development environment. By default the . mdf of it is created inside the user folder in C:\Users\Nome_do_usuario.

After publishing your application on IIS point the connection string to a real instance of your SQL Server. That if you are running on the same machine as the ISS can start with .\

See the example below:

<add connectionString="Server=.\NomeDaInstancia;Database=outraDB;Integrated Security=true" name="DefaultConnection" providerName="System.Data.SqlClient" /> 
  • Yes, I know that the . MDF files stay in that folder, but even after deleting them the app still works and has data saved. How do I know the name of the actual instance of my Server ? I’m sorry I’m ignorant but I don’t know much about IIS or SQL Server. Thanks for the help.

  • Where did you post the database? Where is running your SQL Server (address)?

  • The application was published in a specific folder on the server. Sql is running on the same application server.

  • And how do you connect to this SQL Server that is installed on the server?

  • Through Sql Server Management Studio..

  • Using which address and credentials?

  • (localdb) Mssqllocaldb | windows authentication

  • So it seems to me that you don’t have an SQL Server installed and configured properly on your server

  • Solved. Someone said here, I think, that you shouldn’t use localdb for applications that are published on IIS, and maybe that was the problem, I honestly can’t say for sure if that’s what caused the problem or not. To solve the problem I installed Sqlserver 2017, and after setting a login for a new user and creating a new database everything worked perfectly. Thank you all.

  • 1

    That’s what I said in my reply...

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.