bonjour tout le monde
Ayant commencer l'asp.net je suis un vrai noob dans le domaine. Je voudrais pouvoir afficher le nombre d'user sur le site... pour ca j'ai vu qu'il existait une procédure aspnet_Membership_GetNumberOfUsersOnlin dans la table ASPNETDB.
et donc dans mon code c# dans la fonction onload() j'ai taper
lorsque je démare la page il me dit directement que la connection ne peut etre ouverte
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 SqlConnection oConnection = new SqlConnection("Initial Catalog=ASPNETDB"); string sConnectionString; oConnection.Open(); System.Data.SqlClient.SqlCommand oCommand; string sSQL; // Ecriture de la requête SQL sSQL = "aspnet_Membership_GetNumberOfUsersOnline"; oCommand = new System.Data.SqlClient.SqlCommand(sSQL, oConnection); oCommand.ExecuteNonQuery(); Label1.Text = "nb user " + oCommand.ToString() + "!"; // Fermeture de la connexion oConnection.Close();
quelqu'un pourrait m'aider siouplé?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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)![]()
Partager