Bonjour,
Problème cité maintes et maintes fois, cependant, je n'ai pas trouvé de solution satisfaisante dans mes essais :
Je fais une requête SQL de chargement des factures d'une période (~11000 lignes) qui est très rapide (1 seconde), mais lorsque j'affecte la datatable au datasource du datagried, ça met des plombes (plusieurs minutes)...
Pourquoi ? Y-a-t-il une propriété du Datagried à modifier ?
Merci.
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 Public Function GetFactures(ByVal sTypeFact As String, ByVal dDeb As Date, ByVal dfin As Date) As DataTable Dim oSQLCnx As New SqlConnection Dim oSQLCde As New SqlCommand Dim daListe As New SqlDataAdapter Dim sSQL As String Dim dtListe As New DataTable oSQLCnx.ConnectionString = m_sCnx oSQLCnx.Open() sSQL = String.Format("SELECT F.NumFact 'N°Facture',... " ) oSQLCde.CommandText = sSQL oSQLCde.Connection = oSQLCnx daListe.SelectCommand = oSQLCde daListe.Fill(dtListe) oSQLCnx.Close() Return dtListe End Function Private Sub btnHTNat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHTNat.Click Me.Cursor = Cursors.WaitCursor frmDetail.Show() frmDetail.dgvDetail.SuspendLayout() frmDetail.dgvDetail.DataSource = GetFactures("NATIONAL", dtpDeb.Value.Date, dtpFin.Value.Date) ' <===== Ligne bloquante frmDetail.dgvDetail.ResumeLayout() frmDetail.Text = "Détail des factures 'NATIONAL' du " & dtpDeb.Value.Date & " au " & dtpFin.Value.Date Me.Cursor = Cursors.Default End Sub







Répondre avec citation



Partager