Should I use additional SQL Queries or use FindRows

From: Novice (Novice_at_discussions.microsoft.com)
Date: 06/15/04

  • Next message: rkmoray: "Update data without SQL statement"
    Date: Tue, 15 Jun 2004 12:54:01 -0700
    
    

    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


  • Next message: rkmoray: "Update data without SQL statement"

    Relevant Pages

    • Re: Should I use additional SQL Queries or use FindRows
      ... "FindRows" method or RowFilter property on a DataView instead of issuing ... of the indices that I have built on the database ... by issuing a SQL query for each step or whether it is more efficient to use ... the RowFilter property or FindRows method? ...
      (microsoft.public.dotnet.framework.adonet)
    • RE: Database to Data Structure
      ... Why don't you use the ADO.NET DataSet object to store the data? ... Use a ODBCDataAdapter to fill a DataSet object with your query and then you can hold your data locally inside a DataSet object... ... > Hope it makes sense (I'm fairly confident, however, that there won't> be a way to this automatically - i.e. without manually extracting the> data and manually populating my own data store). ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Do not get data!!!!!
      ... previous post re ADO not raising an exception as I am using lots of ... TADOQuery components? ... try to use the dataset not the query while you are converting. ... > quirks that dont exist in the dataset object. ...
      (borland.public.delphi.database.ado)
    • Re: fastest component for microsoft access
      ... feature rich also! ... I add records by executing Insert Query and not the dataset object where in you add a new record and then update it, ...
      (borland.public.delphi.thirdpartytools.general)
    • Easiest way to query Dataset and return a Dataset
      ... I'm writing a function that is passed a Dataset object, performs a query on ... the returned array of DataRow objects to a Dataset using a loop and returns ...
      (microsoft.public.data.ado)