Bonjour, j'ai un énorme problème depuis plusieurs jours.

Je souhaite me connecter ma base pour faire des insertions. Mais j'ai une erreur d'instance quand j'essaie d'ouvrir la connexion SQL. Je ne sais pas d’où elle vient.

J'ai vérifié mes informations de connexion (copier/coller de la chaine de connexion de BD dans VS 2015), vérification du port 1433, Protocoles TCP/iP activé, autorisation de connexion à la BD, exception dans le pare-feu..., bref tout.

J'ai fait plusieurs recherche sur google sans rien trouvé.

je ne sais vraiment pas d’où ça peut venir. Le code est bon, je pense que c'est un problème de configuration du server SQL ou d'autorisation peut être ?

SQL Server 2012

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 SqlConnection myConnection = new SqlConnection();
            string connectionString = @"Data Source= SRV-SHAREPOINT\\SQLEXPRESS; User ID=wpndf; Pwd=*****; Initial Catalog=WPNDF; Integrated Security=true;";
            myConnection.ConnectionString = connectionString;
 
            if (myConnection.State == ConnectionState.Closed)
            {
                try{ 
                    myConnection.Open();
                    SqlCommand maCommande = new SqlCommand("INSERT INTO NDF (idNDF,nom,prenom,avance_recu) VALUES ('2','" + Nom.Text + "','" + Prenom.Text + "','" + Avance_recu.Text + "')",myConnection);
                    maCommande.ExecuteReader();
                }
                catch(SqlException ex) { MessageBox.Show(ex.Message); }
             }

Nom : screen2.png
Affichages : 2328
Taille : 42,5 Ko

Nom : screen1.png
Affichages : 1599
Taille : 9,6 Ko

Code d'erreur :

L'exception System.InvalidOperationException s'est produite
HResult=-2146233079
Message=Échec d'instance.
Source=System.Data
StackTrace:
à System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, Boolean isFirstTransparentAttempt, SqlAuthenticationMethod authType)
à System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover, Boolean isFirstTransparentAttempt)
à System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
à System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
à System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
à System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
à System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
à System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
à System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
à System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
à System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
à System.Data.SqlClient.SqlConnection.Open()
à SharePoint.VisualWebPart1.VisualWebPart1.Button1_Click(Object sender, EventArgs e)
InnerException: