优化SQL VB.NET结果的另一种方法

优化SQL VB.NET结果的另一种方法,sql,windows,vb.net,winforms,datagridview,Sql,Windows,Vb.net,Winforms,Datagridview,我遇到一些缓慢的问题,正在尝试用此代码刷新我的datagrid, 我试图做的是跨变量(selltype_代码)操作列 确保关闭了轴网柱的所有自动调整大小设置。这大大降低了价格。在执行刷新之前,将网格自动ResizeMode设置为“无”。不要选择表中的所有项目。它增长得越大,代码看起来就越慢。引入分页。为什么不使用后台工作程序组件来执行冗长的工作,以避免ui迟缓的行为 objConn.Open() Dim sqlConn As String = ("SELECT item

我遇到一些缓慢的问题,正在尝试用此代码刷新我的datagrid, 我试图做的是跨变量(selltype_代码)操作列


确保关闭了轴网柱的所有自动调整大小设置。这大大降低了价格。在执行刷新之前,将网格自动ResizeMode设置为“无”。

不要选择表中的所有项目。它增长得越大,代码看起来就越慢。引入分页。为什么不使用后台工作程序组件来执行冗长的工作,以避免ui迟缓的行为
objConn.Open()

            Dim sqlConn As String = ("SELECT item_code, item_name, item_quantity, selltype_code, item_selldetail FROM qa_items")
            Dim objDataAdapter As New MySqlDataAdapter(sqlConn, objConn)
            Dim ds As New DataSet

            objDataAdapter.Fill(ds, "items")

            'Fill datagridview with FOR CICLE
            For i As Int16 = 0 To ds.Tables("items").Rows.Count - 1
                If ds.Tables("items").Rows(i).Item("selltype_code") = 1 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(3, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail") 'Valor para Precio
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                ElseIf ds.Tables("items").Rows(i).Item("selltype_code") = 2 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(5, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                ElseIf ds.Tables("items").Rows(i).Item("selltype_code") = 3 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(4, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                Else
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(6, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                    End With
                End If

            Next i

            objConn.Close()