connexion SQL Server 2008
Bonjour,
je suis entrain de commencer à programmer en ASP.net (C#) sous Visual Studio.
Je voudrai me connecter a une Base de Donnée sous SQL Server 2008
J'ai trouvé la syntaxe pour exécuter mes requêtes mais j'ai besoin du System.Data.SqlClient, cependant je n'arrive pas a l'inclure
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <%@ Page Title="Page d'accueil" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%$
using System.Data ;
using System.Data.SqlClient ;
%>
<%
string con_string = @"data source=localhost ; initial rated=FOLLEDEPERLE3; integrated security=true";
SqlConnection con_fdp;
con_fdp=new SqlConnection();
con_fdp.ConnectionString=con_string;
%>
<html>
<body>
Bonjour test connexion BDD !!<br />
<%
con_fdp.Open();
string query1 = "select count(*) from F_ARTICLE";
SqlCommand sql;
sql = new SqlCommand();
sql.CommandText = query1;
sql.CommandType = CommandType.Text; // valeur par defaut
sql.Connection = con_fdp;
int nb = (int)sql.ExecuteScalar();
Label1.Text = string.Format("Nb Article : {0}", nb);
con_fdp.Close();
%>
<br />hello
</body>
</html> |
Pouvez vous m'aider ?