Salut,

j utilise VStudio 2005, et C# ... j apprend a utiliser C# avec les bases de données, j utilise SQL server express edition.

et j utilise SQL server management studio express comme UI.

j ai fait 1 petite application qui accede a 1 base de données et affiche ces élements dans liste-box.

le problem c que j'obtient tjrs une exception lors de l execution:

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)
j ai fait qlq recherches... concernant le remote connection sous sql

j ai configuré le DataEngine de mon serveur en utilisant le Surface area configuration for services and connections

en configurant le remote connection en TCP/IP et named pipes.

j'ai ajouté 1 exception dans le firewall de windows concernant sqlservr.

mais rien a faire j'obtient tjrs la meme exception.

voici mon code:

note: P4 est le nom de mon serveur
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
 
 
string strConnection = "server=P4; uid=sa; pwd=good; database=MyData";
string strCommand = "Select ID,name,type from Inventory";
 
SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand, strConnection);
 
DataSet dataSet = new DataSet();
 
dataAdapter.Fill(dataSet, "Inventory");
 
DataTable dataTable = dataSet.Tables[0];
 
 
foreach (DataRow dataRow in dataTable.Rows)
{
   lbProducts.Items.Add(dataRow["ID"] + " -- " + dataRow["name"] " -- "
+ dataRow["type"]);
}