FMabey
asked on
Very slow dataview filter
Hi all,
I have a combobox bound to a dataview/dataset. Under the CellEnter event of a datgridview I have the following code:
Private Sub DGV_Structure_CellEnter(By Val sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lEventArgs ) Handles DGV_Structure.CellEnter
DV_ContDraw.RowFilter = "" 'Clear filter
DV_ContDraw.RowFilter = "Cont = " & TXT_Contract.Text & " AND Str = '" & DGV_Structure.Rows(DGV_Str ucture.Cur rentRow.In dex).Cells ("RFIStr") .Value & "'"
CB_DrawNo.SelectedText = ""
End Sub
This filters the dataview that fills the combobox and therefore shows a different list depending upon which row the user selects. My issue is that this is not instant. There is a noticable delay when the user selects a row while the combobox gets filtered through the dataview.
Does anyone know why there could be such a delay and is there a better way of doing this whilst getting the same result?
I have replaced the datafilter code with the following:
SqlConnection1.Open()
'Run a select command on the dataadapter to filter out only the required contract and structure (Section)
SQL_ContDraw.Parameters("@ Cont").Val ue = "" & TXT_Contract.Text & ""
SQL_ContDraw.Parameters("@ Str").Valu e = "" & DGV_Structure.Rows(DGV_Str ucture.Cur rentRow.In dex).Cells ("RFIStr") .Value & ""
SDA_ContDraw.SelectCommand = SQL_ContDraw
SQL_ContDraw.ExecuteNonQue ry()
SDA_ContDraw.Fill(DS_ContD raw1) ' Fill the dataset (this is used to fill the dataview)
SqlConnection1.Close()
Introducing Parameters into my dataadapter and this works a treat. However, I can't help but think that calling the database everytime I move a row is a bit excessive!
Cheers
I have a combobox bound to a dataview/dataset. Under the CellEnter event of a datgridview I have the following code:
Private Sub DGV_Structure_CellEnter(By
DV_ContDraw.RowFilter = "" 'Clear filter
DV_ContDraw.RowFilter = "Cont = " & TXT_Contract.Text & " AND Str = '" & DGV_Structure.Rows(DGV_Str
CB_DrawNo.SelectedText = ""
End Sub
This filters the dataview that fills the combobox and therefore shows a different list depending upon which row the user selects. My issue is that this is not instant. There is a noticable delay when the user selects a row while the combobox gets filtered through the dataview.
Does anyone know why there could be such a delay and is there a better way of doing this whilst getting the same result?
I have replaced the datafilter code with the following:
SqlConnection1.Open()
'Run a select command on the dataadapter to filter out only the required contract and structure (Section)
SQL_ContDraw.Parameters("@
SQL_ContDraw.Parameters("@
SDA_ContDraw.SelectCommand
SQL_ContDraw.ExecuteNonQue
SDA_ContDraw.Fill(DS_ContD
SqlConnection1.Close()
Introducing Parameters into my dataadapter and this works a treat. However, I can't help but think that calling the database everytime I move a row is a bit excessive!
Cheers
I would think that setting the filter for every cell is excessive. You would want to attach to the RowEnter instead.
ASKER
Thank for your reply. Agreed, but I've tried putting the filter on the rowenter but I get the following error:
Object reference not set to an instance of an object.
Object reference not set to an instance of an object.
What value is Nothing (I have no way to tell from here)?
ASKER
DGV_Structure.CurrentRow.I ndex).Cell s("RFIStr" ).Value
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've not abandoned this question... I've just been moved onto another project for a bit. I'll get back to this shortly and post my findings! Thanks for your patience!
ASKER
Hi guys,
Just to say once again, this question isn't being abandoned... I'm just working on another progrect for the time being... When I get back to it I'll try out the suggestions!
Just to say once again, this question isn't being abandoned... I'm just working on another progrect for the time being... When I get back to it I'll try out the suggestions!
ASKER
Thanks for your patience... That works better than the cellenter. Although it's still not quite as smooth as using the parameters. However, it's not a noticable difference so I am going to go with the dataview filters due to their practicality.
Thanks again.
Thanks again.