Server Error in '/' Application.

giovedì 19 aprile 2007 - 18.16

amedeo Profilo | Newbie

Salve a tutti,

Ho pubblicato un sito ma quando cerco di connetermi al DB mi da il seguente errore:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


In locale va tutto bene ma l'accesso su IE mi genera errore, il sito è stato fatto con VS 2005 professional.

Grazie per le risposte

Saluti Amedeo

martinez Profilo | Senior Member

Ciao

Il problema è sicuramente relativo alla stringa di connessione... controlla che la stringa di connessione che hai uploadato sul server sia giusta, cioè che punti al database presente sul server e non a quello locale della tua macchina!

Saluti

amedeo Profilo | Newbie

Grazie per la risposta,

Ho iniziato adesso a cimentarmi con VS 2005. Come faccio a collegarlo al DB del server?

Grazie Amedeo

martinez Profilo | Senior Member

per rispondere alla tua domanda dovrei conoscere per bene i parametri del tuo hosting SQL... in linea generale nel caso in cui si tratti di SQL 2005 è facile ricondursi a questa regola di base:

immettere nel proprio web.config una stringa di connessione come questa:

<add name="objConn" connectionString="Data Source=XXX.XXX.XXX.XXX;User ID=latuauser;password=latuapassword"
providerName="System.Data.SqlClient"/>

i parametri sopra elencati tipo: Data Source; User ID e password se non li conosci devi chiederli al tuo provider che ti fornisce lo spazio SQL

per completezza, è possibile richiamare dalla propria applicazione la connessione utilizzando qualcosa di simile:

SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["objConn"].ConnectionString);

spero di essere stato utile ciao!
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5