Salve,

ho un script .aspx con il quale effettuo l'upload di un'immagine, il suo resize e la creazione della miniatura.

Vorrei effettuare il salvataggio all'interno del database di tipo Sql, ma ho dei problemi.

Per prima cosa ho aggiunto in cima alla pagina:

<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>

Successivamente dopo il salvataggio dell'immagine apro la connessione:

Codice PHP:
string nomedelfile Path.GetFileName(uploadedFiles[0].FileName);
SqlConnection connection = new SqlConnection();
connection.ConnectionString "Data Source=ip_Server; Initial Catalog=Nome_Database; User Id=nome_utente; Password=password";
connection.Open(); 
Dopo di che effettuo la insert:
Codice PHP:
string SQL "INSERT INTO prova (picture1) VALUES ('" nomedelfile "')";

SqlCommand comando = new SqlCommand(SQLconnection);

comando.CommandText SQL;
try
{
   
comando.ExecuteNonQuery();
}
catch (
Exception ex)
{
   
Response.Write(ex.ToString());
}
finally
{
   
connection.Close();

L'upload lo effettua correttamente ma per l'inserimento nel db, mi restituisce quest'errore:
Codice PHP:
 An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (providerNamed Pipes Providererror40 Could not open a connection to SQL Server)
DescriptionAn unhandled exception occurred during the execution of the current web requestPlease review the stack trace for more information about the error and where it originated in the code.

Exception DetailsSystem.Data.SqlClient.SqlExceptionAn error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (providerNamed Pipes Providererror40 Could not open a connection to SQL Server
Come posso risolvere??

Grazie, Kuilsera