Bonjour,

je n'arrive pas à afficher les données résultant de me requête dans une grille.

Voici mon code :

entête de fiche :
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
23
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WFA_sql
{
    public partial class Form1 : Form
    {
        string StrConnexion;
        string StrSQL;
 
        public Form1()
        {
            InitializeComponent();
 
        }
Bouton activation de la requête :
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
23
24
25
26
        private void button2_Click(object sender, EventArgs e)
        {
            StrSQL = TB_SQL.Text;
            StrConnexion = "Data Source=HPWFRED\\SQL2008FR;Integrated Security=SSPI";
MessageBox.Show(StrConnexion);
MessageBox.Show(StrSQL);
            SqlConnection connexionSQL = new SqlConnection(StrConnexion);
            try
            {
                SqlCommand commandeSQL = new SqlCommand(StrSQL, connexionSQL);
                DataSet datasetSQL = new DataSet();
                SqlDataAdapter dataSQL = new SqlDataAdapter(commandeSQL);
                connexionSQL.Open();
                dataSQL.Fill(datasetSQL);
                DGV_SQL.DataSource = dataSQL;
                DGV_SQL.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connexionSQL.Close();
            }
        }
Je précise : BD sur serveur SQL Server 2008.

A +