G
Guest
Hi all, currently my application generates a DataSet object from a query issued to the database.
Then it uses some of the values from that DataSet object to send off further queries and so on.
However, I'm starting to wonder if it might be more efficient to use the "FindRows" method or RowFilter property on a DataView instead of issuing further queries.
Basically, I could retrieve all of the data into my DataSet and then create DataViews on that DataSet to do what I'm currently doing with a number of SQL queries.
However, the values I'm retrieving from the DataSet do not belong to any of the indices (primary key or otherwise) that I have built on the database tables. So it looks like I will have to use the "Sort" method before I can use the FindRows method.
Besides which, I don't know how to FindRows with the Null value (I'm guessing I just put Nothing as the object parameter). This is the code I've tried to use:
Dim myView As DataView
myView = myDataSet.Tables("some_table").DefaultView()
myView.Sort() = "column_in_table"
myView.FindRows(System.DBNull)
If I use the above code, I get the error:
Expecting 1 value(s) for the key being indexed, but received 0 value(s).
I'm guessing I need to be using "System.DBNull" somehow but I'm not sure how.
Or should I be using the RowFilter property:
myView.RowFilter = "column_in_table = NULL"
However, if I do it using the RowFilter I don't know how to generate the array of DataRowView objects. I need this since I'm not directly binding this data to a web control.
To summarize:
1. How should one determine whether it is more efficient to navigate data by issuing a SQL query for each step or whether it is more efficient to use the RowFilter property or FindRows method?
2. How can you use the FindRows method to find rows where an attribute/value in a column is set to NULL?
3. How can you get the array of DataRowObjects once you set the RowFilter property to the query string of your choosing?
Thanks,
Novice
Then it uses some of the values from that DataSet object to send off further queries and so on.
However, I'm starting to wonder if it might be more efficient to use the "FindRows" method or RowFilter property on a DataView instead of issuing further queries.
Basically, I could retrieve all of the data into my DataSet and then create DataViews on that DataSet to do what I'm currently doing with a number of SQL queries.
However, the values I'm retrieving from the DataSet do not belong to any of the indices (primary key or otherwise) that I have built on the database tables. So it looks like I will have to use the "Sort" method before I can use the FindRows method.
Besides which, I don't know how to FindRows with the Null value (I'm guessing I just put Nothing as the object parameter). This is the code I've tried to use:
Dim myView As DataView
myView = myDataSet.Tables("some_table").DefaultView()
myView.Sort() = "column_in_table"
myView.FindRows(System.DBNull)
If I use the above code, I get the error:
Expecting 1 value(s) for the key being indexed, but received 0 value(s).
I'm guessing I need to be using "System.DBNull" somehow but I'm not sure how.
Or should I be using the RowFilter property:
myView.RowFilter = "column_in_table = NULL"
However, if I do it using the RowFilter I don't know how to generate the array of DataRowView objects. I need this since I'm not directly binding this data to a web control.
To summarize:
1. How should one determine whether it is more efficient to navigate data by issuing a SQL query for each step or whether it is more efficient to use the RowFilter property or FindRows method?
2. How can you use the FindRows method to find rows where an attribute/value in a column is set to NULL?
3. How can you get the array of DataRowObjects once you set the RowFilter property to the query string of your choosing?
Thanks,
Novice