Running queries on a DataSet that I've constructed at run-time RRS feed

  • Question




    I am trying to run an SQL query on a dataset that contains two tables that I've created and filled with data at run-time. It seems in order to do this I need to create an SQLConnection->SQLDataAdapter->SQLCommand; however, I have been unable to find a way to get an SQLConnection to an "in-memory" database such as this. Is this possible and if so, how can I do this?





    Wednesday, May 14, 2008 8:33 PM

All replies

  • You cannot run SQL query against DataSet. You can use SQL query to load data into DataSet from some database. If you want to query information from DataSet, you would need to use LINQ.


    Thursday, May 15, 2008 9:43 AM

    So, is it possible to dynamically make LINQ queries at runtime against a runtime-created DataSet? Is it possible to make this queries using more that one DataSet at a time?
    Monday, July 28, 2008 4:14 AM
  • Yes it is possible to make Linq queries at runtime. All you have to do is have some type of user action trigger the Linq query creation. So lets say a user types some input into a text box and then clicks Filter. On the OnClick event of the filter. For example here is a a code snippet that does a simple where expression. Perhaps the text box has a integer that is used with to create the expression.


    Dim numbers = TestDS.Tables("Numbers").AsEnumerable

    Dim lowNums = From r In numbers _
            Where r("number") < 5 _
            Select r


    'lowNums now contains a DataView that is a list of enumerable DataRowView


    Here are code snippets on how to use Linq To DataSet




    Chris Robinson

    Software Developer in Test- DataSet

    Tuesday, August 19, 2008 9:39 PM