Bonjour,
je veux afficher des informations sur un datagridview avec une connexion sqlserver. J'ai fait le code suivant:
Mon probléme c'est que je ne sais pas comment le relier avec mon connectionstring qui se trouve dans le webconfig que voici:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 protected void Page_Load(object sender, EventArgs e) { SqlDataSource SqlDataSource1 = new SqlDataSource(); SqlDataSource1.DataSourceMode = SqlDataSourceMode.DataSet; SqlDataSource1.SelectCommand = " Select substring (MAILET, charindex('@', MAILET) + 1, 4000), NOMET, PRENOMET from Matable "; BoundField maColonne = new BoundField(); GridView1.Columns.Add(maColonne); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); }
J'arrive pas afficher ces informations, pouvez-vous m'aider?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 <connectionStrings> <add name="projet_gspConnectionString" connectionString="Data Source=monpc\SQLEXPRESS;Initial Catalog=projet;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings>
Merci d'avance.
Partager