Bonjour,

je voudrais afficher les résultats de ma requette a travers un datagrid.
j ai un formulaire je saisi un nom %abe% et la bd me renvoie tous les contacts demandés
J'arrive apparement a me connecter, quand j'inscrit un nom dans le formulaire, au submit ,je ne recoit que l'en tete du datagrid mais pas de données.
Merci de m'aider
j'utilise vs 2008 et sql server 2005

Je sais plus comment faire.
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
global.asax
Public Class Global_asax
        Inherits System.Web.HttpApplication
 
        Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
            ' on crée un objet produits
            Dim objInfos As InfosData
            Try
                objInfos = New InfosData(ConfigurationManager.AppSettings("SQLStringConnection"))
                ' on met l'objet dans l'application
                Application("objInfos") = objInfos
                ' pas d'erreur
                Application("erreur") = False
            Catch ex As Exception
                'il y a eu erreur, on le note dans l'application
                Application("erreur") = True
                Application("message") = ex.Message
            End Try
        End Sub
 
 
le controleur
 
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            ' on regarde si l'application est en erreur
            If CType(Application("erreur"), Boolean) Then
                ' l'application ne s'est pas initialisée correctement
                Dim erreurs As New ArrayList
                erreurs.Add("Application momentanément indisponible (" + CType(Application("message"), String) + ")")
                afficheErreurs(erreurs, False)
                Exit Sub
            End If
            '1ère requête
            If Not IsPostBack Then
                ' on affiche le formulaire vide
                afficheFormulaire()
            End If
        End Sub
 
Private Sub afficheListeInfo(ByVal donnees As DataSet)
            Dim afficheLien As Boolean
            With DataGrid1
                .DataSource = donnees
                .PageSize = 5
                .CurrentPageIndex = 0
                .DataBind()
            End With
            ' on affiche la vue [résultats]
            vueListeInfo.Visible = True
            vueFormulaire.Visible = True
            lnkErreurs.Visible = afficheLien
            vueDetailListe.Visible = False
            vueModifierInfo.Visible = False
            vueErreur.Visible = False
        End Sub
----
 
Sub btnEnvoyer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
 
            Dim chaineConnexionSQL As String = "ma base"
            Dim commande As String
            Dim objInfosData As InfosData = New InfosData(chaineConnexionSQL)
 
            ' page valide ?
            If Not Page.IsValid Then
                afficheFormulaire()
                Exit Sub
            End If
            ' exécution de la requête SELECT client
            Dim donnees As DataSet
            commande = "select ca_contact.last_name,ca_contact.first_name,ca_organization.org_name,ca_location.location_name,ca_location.address_1,ca_location.address_2,ca_location.city from ca_contact left outer join ca_organization on ca_contact.organization_uuid = ca_organization.organization_uuid left outer join ca_location on ca_contact.location_uuid = ca_location.location_uuid where ca_contact.last_name like '@txtSelect'"
            Try
                donnees = objInfosData.getDataSet(commande)
            Catch ex As Exception
                Dim erreurs As New ArrayList
                erreurs.Add("erreur d'accès à la base de données (" + ex.Message + ")")
                afficheErreurs(erreurs, True)
                Exit Sub
            End Try
            ' tout va bien - on affiche la liste des informations
            afficheListeInfo(donnees)
            ' on met les données dans la session
            Session("donnees") = donnees
 
        End Sub
 
---
classe d,acces aux données
 
 Public Class InfosData
 
        Private chaineConnexionSQL As String = "ma base"
        Public Sub New(ByVal chaineConnexionSQL As String)
            ' on mémorise la chaîne de connexion
            Me.chaineConnexionSQL = chaineConnexionSQL
        End Sub
 
        Public Function getDataSet(ByVal commande As String) As DataSet
 
            Dim objInfos As InfosData = New InfosData(chaineConnexionSQL)
            ' on crée un objet DataAdapter pour lire les données de la source SQL
            Dim adaptateur As New SqlDataAdapter(commande, chaineConnexionSQL)
            ' on crée une image en mémoire du résultat du select
            Dim contenu As New DataSet
            Try
                adaptateur.Fill(contenu)
            Catch e As Exception
                Throw New Exception("Erreur d'accès à la base de données (" + e.Message + ")")
            End Try
            ' on rend le résultat
            Return contenu
        End Function
 
    End Class