1
I am using SQL Server 2012, and when publishing my application, both on the client server and on my pc everything works well. As connection strings
for the BD are correct, everything looks good. Now where is the problem? When trying to authenticate a user I get the error:
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. (Preview: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an Automatic instance. See the Windows Application Event log for error Details. )
In my file Authconfig.Cs have:
WebSecurity.InitializeDatabaseConnection("Server=" + ConfigurationManager.AppSettings["Server"] + ";Database=" + ConfigurationManager.AppSettings["Database"] + ";Integrated Security=False;User ID=" + ConfigurationManager.AppSettings["UserID"] + ";Password=" + ConfigurationManager.AppSettings["Password"] + ";MultipleActiveResultSets=true;",
"System.Data.SqlClient", "Users", "UserId", "UserName", autoCreateTables: true);
Where will I get the data (Server, Database, Userid and Password) to my Web.config
Web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MvcTesteLayout-20131023143453;Integrated Security=False;AttachDBFilename=|DataDirectory|\aspnet-MvcTesteLayout-20131023143453.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="Server" value="CPSI0024\SQLEXPRESS" />
<add key="Database" value="OleoTorres" />
<add key="UserID" value="OleoTorres" />
<add key="Password" value="oleotorres" />
<add key="ServerArtSoft" value="OLEOTORRES2014" />
<add key="UserServerArtSoft" value="Admin" />
<add key="PassServerArtSoft" value="passServ" />
<add key="pathFiles" value="D:/uploadsOleotorres"></add>
<add key="pathFilesGerarPDF" value="D:/gerarPDFOleotorres"></add>
</appSettings>
I’ve looked for several ways to solve it, but I couldn’t find a solution to solve the problem...
This error means that the SQL Server instance was not found. You can put your file
Web.config
in the question?– Leonel Sanches da Silva
@Ciganomorrisonmendez, edited
– CesarMiguel
@Cesarmiguel, try to change your string Connection by pointing to the server’s IP or DNS, even if it is the machine itself. Check in your SQL Managment Studio which is the server name and use similar.
– Roger Barretto
Yeah, but my server name in SQL Managment Studio is "CPSI0024 SQLEXPRESS", which is what I’m using
– CesarMiguel
@Cesarmiguel Try to assemble the
connectionString
out of the call of the methodInitializeDatabaseConnection
and in debug check how toconnectionString
was mounted.– Leonel Sanches da Silva
@Gypsy, I checked in debug and the name of connectionString is correct. I have the application working properly, only when I publish it, it stops the part of the users. Is there perhaps no option in SQL Server? Or is this error even pointing to bad webconfig configuration?
– CesarMiguel
@Cesarmiguel Where its application is published?
– Leonel Sanches da Silva
Both on my machine (tests) and on the client server
– CesarMiguel