Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to make VB.NET DataGridView as fast as VB6 DataGrid?

$
0
0

I have two programs: one written in VB6; the other in VB.NET. Using a table with 41025 records the VB6 version fills a DataGrid in about 4 seconds. The VB.NET version takes nearly three minutes to fill a DataGridView. How can the speed of the VB.NET version be improved?

They both use the SQL statement:
SELECT * FROM [TblSchema].[TblName] ORDER BY [DateTime]

Here's the VB6 version:

  'create recordset to hold sql query result
  Set adoVTRS = New ADODB.Recordset
  adoVTRS.Open sSQL, objImExportMgr.DbConn, adOpenStatic, adLockOptimistic

  Set adcViewTable.Recordset = adoVTRS
  Set grdViewTable.DataSource = adcViewTable.Recordset
  grdViewTable.Refresh


Here's the VB.NET version:

    Try
      GridSQLCommand.Connection.Open()
      GridSQLDataAdapter.Fill(GridDataSet)
      GridSQLCommand.Connection.Close()

      Me.DataGridView2.DataSource = GridDataSet.Tables(0).DefaultView
      ' Resize the DataGridView columns to fit the newly loaded content.
      ' Me.DataGridView2.Refresh()
      Me.DataGridView2.AutoGenerateColumns = True
      Me.DataGridView2.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells)
      Me.BindingNavigator2.BindingSource.DataSource = Me.DataGridView2.DataSource
      Me.Cursor = Cursors.Default

    Catch ex As SqlException
      HandleFormErrors()
    End Try


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>