Click here to Skip to main content
15,560,045 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi all
i have a asp.net website that i want to run on iis
but when i cick on browse in iis manager
i get this error in index.aspx page

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)


i really dont know how to solve it but in web.config file i declare the sql db and everything about database like below

XML
<!-- WebConfigCod -->

      <connectionStrings>
        <add name="DatabaseConnectionString1" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True"
          providerName="System.Data.SqlClient" />
      </connectionStrings>

<!-- WebConfigCode -->


What I have tried:

i tried to use ip port instead of named instance but i dont know how to do it
Posted
Updated 20-Nov-17 2:30am
v2

1 solution

The error message is pretty explicit!
The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
And it means what it says: the SQL server you are trying to access - a local DB - is not installed or is not running.

It's unlikely that an SQL server instance for a website will be LOCALDB - it's normally a named instance, and it almost certainly won't use integrated security, particularly on a shared hosting service. Also remember that IIS doesn't run under your user account, so SQL need to be configured to work with it.

So start by looking at your DB information from your provider, and then try this: Simple SQL Connection String Creation[^]

Oh, and by the way ... attaching a DB is only for development, it only works on SQL Express and can't be used in production. Add that to the IIS user problem and you would probably get "Access violation" errors trying to attach the DB for your website anyway. The DB should be installed into SQL and used directly, not attached.
 
Share this answer
 
v2
Comments
Member 13019612 21-Nov-17 4:35am    
i understand you but problem is i dont know how to do it you say ???
OriginalGriff 21-Nov-17 4:51am    
I did - as far as I can without being at your system!
Did you follow the link?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900